Skip to content

hayletdomybest/match_engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Match Engine

Description

A match engine built on top of Raft, designed for exchange transactions.

Build

To build the project, run the following command:

go build -o ./out/mind ./app/main.go

Initialization

Single Mode

To initialize a single node:

./out/mind server init --home ./private/node1

Cluster Mode

To initialize a cluster with two nodes:

./out/mind server init --home ./private/node1
./out/mind server init --home ./private/node2

Configuration matching server

Single Mode

./private/node1/app_config.json

{
  "api_port": 3000,
  "node_id": 1,
  "node_url": "http://127.0.0.1:8081",
  "peers": {
    "1": "http://127.0.0.1:8081",   
  },
  "join": false,
  "data_dir": "",
  "etcd_endpoints": []
}

Cluster Mode

./private/node1/app_config.json

{
  "api_port": 3000,
  "node_id": 1,
  "node_url": "http://127.0.0.1:8081",
  "peers": {
    "1": "http://127.0.0.1:8081",
    "2": "http://127.0.0.1:8082"    
  },
  "join": false,
  "data_dir": "",
  "etcd_endpoints": []
}

./private/node2/app_config.json

{
  "api_port": 3001,
  "node_id": 2,
  "node_url": "http://127.0.0.1:8082",
  "peers": {
    "1": "http://127.0.0.1:8081",
    "2": "http://127.0.0.1:8082"    
  },
  "join": false,
  "data_dir": "",
  "etcd_endpoints": []
}

Run matching server

Single Mode

To run a single node:

./out/mind server run --home ./private/node1

Cluster Mode

To run a cluster with two nodes:

./out/mind server run --home ./private/node1
./out/mind server run --home ./private/node2

Using etcd for service discovery

docker-compose -f ./deploy/etcd-docker-compose.yml up -d

note: should choose proper "platform"

platform: linux/arm64

Testing

Append Message

curl -X POST http://127.0.0.1:3000/api/v1/helloworld/message -H "Content-Type: application/json" -d '{"message":"version3"}'

Get Message

curl -X GET http://127.0.0.1:3000/api/v1/helloworld/messages

Get Leader

curl -X GET http://127.0.0.1:3000/api/v1/explorer/leader

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages