From fe9d217b60136bf05d4d4d61f09497fa59f38197 Mon Sep 17 00:00:00 2001 From: Mohamed Sohail Date: Wed, 8 Mar 2023 17:19:33 +0300 Subject: [PATCH] docs: add README, add Makefile dev: add Makefile docs: add README fix: Makefile --- Dockerfile | 2 ++ Makefile | 17 +++++++++++++++++ README.md | 17 +++++++++++++++++ cmd/service/init.go | 1 + cmd/service/main.go | 2 ++ internal/pub/js_pub.go | 10 +++++----- 6 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 Makefile create mode 100644 README.md diff --git a/Dockerfile b/Dockerfile index ed46005..87fc510 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,7 @@ RUN go mod download COPY . . RUN go build -o cic-custodial -ldflags="-X main.build=${BUILD_COMMIT} -s -w" cmd/service/* + FROM debian:bullseye-slim ENV DEBIAN_FRONTEND=noninteractive @@ -25,6 +26,7 @@ COPY --from=build /build/cic-custodial . COPY migrations migrations/ COPY config.toml . COPY queries.sql . +COPY LICENSE . EXPOSE 5000 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2168386 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +BIN := cic-custodial +BUILD_CONF := CGO_ENABLED=1 GOOS=linux GOARCH=amd64 +BUILD_COMMIT := $(shell git rev-parse --short HEAD 2> /dev/null) + +.PHONY: build + +clean: + rm ${BIN} + +build: + ${BUILD_CONF} go build -ldflags="-X main.build=${BUILD_COMMIT} -s -w" -o ${BIN} cmd/service/* + +run: + ${BUILD_CONF} go run cmd/service/* + +run-debug: + ${BUILD_CONF} go run cmd/service/* -debug diff --git a/README.md b/README.md new file mode 100644 index 0000000..008d3f1 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# cic-chain-events + +![GitHub release (latest by date)](https://img.shields.io/github/v/release/grassrootseconomics/cic-custodial) +![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/grassrootseconomics/cic-custodial/release.yaml) +[![Go Report Card](https://goreportcard.com/badge/github.com/grassrootseconomics/cic-custodial)](https://goreportcard.com/report/github.com/grassrootseconomics/cic-custodial) + +> CIC Custodial + +Experimental custodial API. + +## Documentation + +- [Usage](docs/usage.md) + +## License + +[AGPL-3.0](LICENSE). \ No newline at end of file diff --git a/cmd/service/init.go b/cmd/service/init.go index c6c7d63..5b1e5a7 100644 --- a/cmd/service/init.go +++ b/cmd/service/init.go @@ -212,6 +212,7 @@ func initPub(jsCtx nats.JetStreamContext) *pub.Pub { return pub } + func initSub(natsConn *nats.Conn, jsCtx nats.JetStreamContext, cu *custodial.Custodial) *sub.Sub { sub, err := sub.NewSub(sub.SubOpts{ CustodialContainer: cu, diff --git a/cmd/service/main.go b/cmd/service/main.go index 4f582ff..bc4ada1 100644 --- a/cmd/service/main.go +++ b/cmd/service/main.go @@ -46,6 +46,8 @@ func init() { } func main() { + lo.Info("main: starting cic-custodial", "build", build) + parsedQueries := initQueries() celoProvider := initCeloProvider() postgresPool := initPostgresPool() diff --git a/internal/pub/js_pub.go b/internal/pub/js_pub.go index fcdcf14..64d8c07 100644 --- a/internal/pub/js_pub.go +++ b/internal/pub/js_pub.go @@ -8,8 +8,8 @@ import ( ) const ( - StreamName string = "CUSTODIAL" - StreamSubjects string = "CUSTODIAL.*" + streamName string = "CUSTODIAL" + streamSubjects string = "CUSTODIAL.*" AccountNewNonce string = "CUSTODIAL.accountNewNonce" AccountRegister string = "CUSTODIAL.accountRegister" AccountGiftGas string = "CUSTODIAL.systemNewAccountGas" @@ -39,13 +39,13 @@ type ( ) func NewPub(o PubOpts) (*Pub, error) { - stream, _ := o.JsCtx.StreamInfo(StreamName) + stream, _ := o.JsCtx.StreamInfo(streamName) if stream == nil { _, err := o.JsCtx.AddStream(&nats.StreamConfig{ - Name: StreamName, + Name: streamName, MaxAge: o.PersistDuration, Storage: nats.FileStorage, - Subjects: []string{StreamSubjects}, + Subjects: []string{streamSubjects}, Duplicates: o.DedupDuration, }) if err != nil {