Skip to content

Commit

Permalink
Merge pull request #18 from RTradeLtd/ens
Browse files Browse the repository at this point in the history
Enable Processing Of ENS Requests
  • Loading branch information
bonedaddy authored Nov 27, 2019
2 parents 0696dca + 96021da commit fd09938
Show file tree
Hide file tree
Showing 13 changed files with 663 additions and 46 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/temporal-payment
log/tmp/

pay
21 changes: 21 additions & 0 deletions .scripts/cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#! /bin/bash

# Cross-compile Temporal using gox, injecting appropriate tags.
go get -u github.com/mitchellh/gox

RELEASE=$(git describe --tags)
TARGETS="linux/amd64"

mkdir -p release

gox -output="release/pay-$(git describe --tags)-{{.OS}}-{{.Arch}}" \
-ldflags "-X main.Version=$RELEASE" \
-osarch="$TARGETS" \
./cmd/pay


ls ./release/pay* > files

for i in $(cat files); do
sha256sum "$i" > "$i.sha256"
done
46 changes: 28 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
language: go
go:
- "1.12"
- '1.13'
services:
- docker

- docker
env: GO111MODULE=on

install:
- make vendor

- go mod download
before_script:
- go vet ./...
- go build ./...
- go test -run xxxx ./...

- go vet ./...
- go build ./...
- go test -run xxxx ./...
script:
- go fmt ./...
- go run golang.org/x/lint/golint $(go list ./... | grep -v /vendor/) # golint doesn't ignore vendor - go test -race -short -coverprofile=coverage.txt ./...
- go test -short -race -coverprofile=coverage.txt ./...

- go fmt ./...
- go run golang.org/x/lint/golint $(go list ./... | grep -v /vendor/)
- go test -short -race -coverprofile=coverage.txt ./...
after_success:
- bash <(curl -s https://codecov.io/bash)

notifications:
email: false
- bash <(curl -s https://codecov.io/bash)
before_deploy:
- make release-cli
deploy:
provider: releases
skip_cleanup: true
api_key:
secure: ScDGOmHWYf939IHdhq1QesNQHKbwDOyPpd1EiWtpUb1ROCkOJFppJrovoZN62kUfl+w2iabz8KpOOj5U1tW0t76ZjeLm8FtsoWAUSfMZDGvuCXXqnVSMdGY1jLXLgZcSH/HDTj2tExPq+ZQlfOZjhqprBFXm6KSjbaK63B4Yih0q97c1xPvKixLiA/NnauuJL6pTMFYelQehJVHBtfWctpvUt3jvE/Nc2TrcOsGu83XytD4VlNYEVLDKCaagGbYQSjP9vjEDcviyX/RmpTBYZHFP2b5or3LQkd5Q1kJ5kakm5SdUmFO7Ew9oWbK1YvmTuK7QTFUv8K8BzWqW9bGBHjNXiXqhCyt0+l5GgMddHm76cVHa3ePtCggt7/yffUOON7V5SDBpaTc7rm3d9VC8ioZMiVbfviEfEtA0RCY9u484lhTo6gNJSp3S51WZ5rW7dro5MsQ0DRk4vmjHUmo8+lFCZfaeuplNrb075gdcJQrZC3/bCF+fUyiFXC/WQdj9t40NjYjID+STA+t+Z2P/fmx/9THFy/OnlXVYzSiF+IdSAFDDuTBhYv5U6tKB2vlsCdrP5dymiXjcTtCJu5jdBKRa0eE4G9XLhZsjOt8u+tlveOn7QlsEEf73OeHsZqXrq0uFVPfIXFfjE/p3TbkBMrFQpUgx0whUd/OTKW/JWdI=
file_glob: true
file: release/pay*
on:
tags: true
repo: RTradeLtd/Pay
cache:
directories:
- "$GOPATH/pkg/mod"
- "$HOME/.cache/go-build"
notifications:
email: false
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
TEMPORALVERSION=`git describe --tags`

# Build pay binary
pay:
@make cli
Expand Down Expand Up @@ -25,4 +27,11 @@ gen:
@echo "=================== regenerating code ==================="
$(COUNTERFEITER) -o ./mocks/bch.mock.go \
github.com/gcash/bchd/bchrpc/pb.BchrpcClient
@echo "=================== done ==================="

# Build CLI binary release
.PHONY: release-cli
release-cli:
@echo "=================== cross-compiling CLI ==================="
@bash .scripts/cli.sh
@echo "=================== done ==================="
42 changes: 42 additions & 0 deletions cmd/pay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,48 @@ var commands = map[string]cmd.Cmd{
Description: "Interact with Temporal's various queue APIs",
ChildRequired: true,
Children: map[string]cmd.Cmd{
"ens": cmd.Cmd{
Blurb: "ens queue command",
Description: "Used to launch ens request processing queue",
Action: func(cfg config.TemporalConfig, args map[string]string) {
logger, err := log.NewLogger(logPath(cfg.LogDir, "ens_consumer.log"), *devMode)
if err != nil {
fmt.Println("failed to start logger", err)
os.Exit(1)
}
db, err := newDB(cfg, *dbNoSSL)
if err != nil {
fmt.Println("failed to start db", err)
os.Exit(1)
}
quitChannel := make(chan os.Signal)
signal.Notify(quitChannel, os.Interrupt, syscall.SIGTERM, syscall.SIGINT)
waitGroup := &sync.WaitGroup{}
go func() {
fmt.Println(closeMessage)
<-quitChannel
cancel()
}()
for {
qm, err := queue.New(queue.ENSRequestQueue, &cfg, logger, *devMode)
if err != nil {
fmt.Println("failed to start queue", err)
os.Exit(1)
}
waitGroup.Add(1)
err = qm.ConsumeMessages(ctx, waitGroup, db, &cfg)
if err != nil && err.Error() != queue.ErrReconnect {
fmt.Println("failed to consume messages", err)
os.Exit(1)
}
// this will only be true if we had a graceful exit to the queue process, aka CTRL+C
if err == nil {
break
}
}
waitGroup.Wait()
},
},
"payment": cmd.Cmd{
Blurb: "payment queue sub commands",
Description: "Used to launch various payment queue processors",
Expand Down
Loading

0 comments on commit fd09938

Please sign in to comment.