This is a golang boilerplate for Mixin Bot.
run
./go-boilerplate -f YOUR_KEYSTORE_FILE help
to see the help.
It enables several widely used functionalities by default:
- define new API at
/handler/serve.go
- inject necessary dependences at
/cmd/httpd/httpd.go
and pass them into the handler - implement them under the
/handlers
- build and run
./go-boilerplate -f YOUR_KEYSTORE_FILE httpd [port]
- implement new workers at
/workers
- add the new instance of the workers to
workers
at/cmd/worker/worker.go
- inject necessary dependences at
/cmd/worker/worker.go
and pass them into the handler - build and run
./go-boilerplate -f YOUR_KEYSTORE_FILE worker [health check port]
- implement the handlers at
/messages
- inject necessary dependences at
/cmd/worker/worker.go
and pass them into the handlermessenger
- call the handlers at
/worker/messenger/messenger.go
- put your code at
/worker/syncer/syncer.go:run
to handle the snapshots you need. - inject necessary dependences at
/cmd/worker/worker.go
and pass them into the handlersyncer
- the checkpoint of syncer is stored in the table
properties
with keysyncer:snapshot_checkpoint
, change it if you don't want to wait for a long time.
- only inject the dependences (store, i18n, etc) you need into the workers or apis
- the store methods includes setters/getters and actions, the former are operations to the database, and latter are operations not only related to the database (network request, redis, etc)
feel free to remove any functionality you do not need:
- syncer
/cmd/worker
- the entry command to start workers/worker/syncer
- a worker to sync snapshots from Mixin Network./core
- database model definitions of snapshots and assets/store
- database stores of snapshots and assets
- httpd
/cmd/httpd
- the entry command to start a httpd server/handler
- the HTTP requset handlers
- messenger
/cmd/worker
- the entry command to start workers/worker/messenger
- a worker to handle incoming messages/message/
- the handlers to handle messages
- migrater
/cmd/migrate
- the entry command to migrate database
- the echo command
/cmd/echo
- a simple command to show you how to write a command