Skip to content

Commit

Permalink
Switch to centralized proto
Browse files Browse the repository at this point in the history
  • Loading branch information
jjbubudi committed May 13, 2019
1 parent 5a86145 commit b4627c2
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 54 deletions.
20 changes: 4 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ ifeq ($(ARCH), arm)
ARCH = armhf
endif

PROTO_TOOL = docker run --rm -v `pwd`:/work uber/prototool:1.7.0 prototool
PROTO_PACKAGE := api
PROTO_FILES := $(wildcard $(PROTO_PACKAGE)/*.proto)
GENERATED_CODE := $(patsubst %.proto, %.pb.go, $(PROTO_FILES))

DOCKER_IMAGE := jjbubudi/tides
TAG ?= $(shell git describe --tags 2>/dev/null)
COMMIT ?= $(shell git rev-parse --short HEAD)
Expand All @@ -22,7 +17,7 @@ ifneq ($(TAG),)
endif

.PHONY: build
build: generate
build:
@$(GO) build -o dist/tides cmd/main.go

.PHONY: build-docker
Expand All @@ -48,23 +43,16 @@ push-manifest:
--target "$(DOCKER_IMAGE):$(VERSION)"

.PHONY: run
run: generate
run:
@$(GO) run cmd/main.go

.PHONY: ci
ci: build test

.PHONY: test
test: generate
test:
@$(GO) test ./...

.PHONY: generate
generate: $(GENERATED_CODE)

%.pb.go: %.proto
@$(PROTO_TOOL) generate

.PHONY: clean
clean:
@rm -rf dist/
@rm -rf api/*.pb.go
@rm -rf dist/
20 changes: 0 additions & 20 deletions api/events.proto

This file was deleted.

1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.12
require (
github.com/golang/protobuf v1.3.1
github.com/jasonlvhit/gocron v0.0.0-20190402024347-5bcdd9fcfa9b
github.com/jjbubudi/protos-go v0.0.0-20190513145009-4dcc2b0121af
github.com/nats-io/go-nats-streaming v0.4.2
github.com/stretchr/testify v1.3.0
)
Expand Down
22 changes: 22 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da h1:8GUt8eRujhVEGZFFEjBj46YV4rDjvGrNxb0KMWYkL2I=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand All @@ -23,6 +28,8 @@ github.com/jasonlvhit/gocron v0.0.0-20190402024347-5bcdd9fcfa9b h1:71OQnFj9tBPdc
github.com/jasonlvhit/gocron v0.0.0-20190402024347-5bcdd9fcfa9b/go.mod h1:rwi/esz/h+4oWLhbWWK7f6dtmgLzxeZhnwGr7MCsTNk=
github.com/jjbubudi/go-nats-streaming v0.4.3-0.20190420024036-3a359ddc011c h1:e69ZVJGtbe+EPLa0UI2bcdASNv/f9UkimelliBgz/bA=
github.com/jjbubudi/go-nats-streaming v0.4.3-0.20190420024036-3a359ddc011c/go.mod h1:pevejOzUVyD/s1pr0Ddy9iEFy9WpWH5/K3zJVWGjXZc=
github.com/jjbubudi/protos-go v0.0.0-20190513145009-4dcc2b0121af h1:fb9jwKABgdLeukJK3oVChX5mAs47amdD76w/sFRu9+s=
github.com/jjbubudi/protos-go v0.0.0-20190513145009-4dcc2b0121af/go.mod h1:jHBzJ11mU3JT9xHUlksSd0K2qTIE3S6BUupuC8XFhYs=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/lib/pq v1.1.0 h1:/5u4a+KGJptBRqGzPvYQL9p0d/tPR4S31+Tnzj9lEO4=
Expand All @@ -49,15 +56,30 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
go.etcd.io/bbolt v1.3.2 h1:Z/90sZLPOeCy2PwprqkFa25PdkusRzaj9P8zm/KNyvk=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480 h1:O5YqonU5IWby+w98jVUG9h7zlCWCcH4RHyPVReBmhzk=
golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225 h1:kNX+jCowfMYzvlSvJu5pQWEmyWFrBXJ3PBy10xKMXK8=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a h1:XCr/YX7O0uxRkLq2k1ApNQMims9eCioF9UpzIPBDmuo=
golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4c=
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/grpc v1.20.1 h1:Hz2g2wirWK7H0qIIhGIqRGTuMwTE8HEKFnDZZ7lm9NU=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
16 changes: 8 additions & 8 deletions internal/tides/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/jjbubudi/tides/api"
"github.com/jjbubudi/protos-go/tides"
"github.com/jjbubudi/tides/pkg/observatory"
)

Expand Down Expand Up @@ -39,8 +39,8 @@ func (s *Service) PublishRealTimeTidalData(when time.Time) error {
return err
}

event := &api.TideRecorded{
Timestamp: &timestamp.Timestamp{
event := &tides.TideRecorded{
Time: &timestamp.Timestamp{
Seconds: tidalData.Seconds,
Nanos: int32(tidalData.Nanos),
},
Expand All @@ -62,19 +62,19 @@ func (s *Service) PublishTidalPredictions(when time.Time) error {
return err
}

var predictionsProto []*api.TidePredicted_Prediction
var predictionsProto []*tides.TidePredicted_Prediction
for _, prediction := range predictions {
predictionsProto = append(predictionsProto, &api.TidePredicted_Prediction{
Timestamp: &timestamp.Timestamp{
predictionsProto = append(predictionsProto, &tides.TidePredicted_Prediction{
Time: &timestamp.Timestamp{
Seconds: prediction.Seconds,
Nanos: int32(prediction.Nanos),
},
Meters: prediction.Meters,
})
}

event := &api.TidePredicted{
Timestamp: &timestamp.Timestamp{
event := &tides.TidePredicted{
Time: &timestamp.Timestamp{
Seconds: when.Unix(),
Nanos: int32(when.Nanosecond()),
},
Expand Down
20 changes: 10 additions & 10 deletions internal/tides/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/jjbubudi/protos-go/tides"
"github.com/jjbubudi/tides/pkg/observatory"
"github.com/jjbubudi/tides/api"
"github.com/stretchr/testify/assert"
)

Expand All @@ -18,7 +18,7 @@ func TestCreateService(t *testing.T) {

func TestPublishRealTimeTidalData(t *testing.T) {
var publishedSubject string
var publishedData api.TideRecorded
var publishedData tides.TideRecorded

var tidalData = func(when time.Time) (observatory.TidalData, error) {
return observatory.TidalData{
Expand All @@ -37,8 +37,8 @@ func TestPublishRealTimeTidalData(t *testing.T) {
service := New(tidalData, nilPredictions, publisher)
service.PublishRealTimeTidalData(time.Unix(0, 0))

expectedData := api.TideRecorded{
Timestamp: &timestamp.Timestamp{
expectedData := tides.TideRecorded{
Time: &timestamp.Timestamp{
Seconds: 10000,
Nanos: 0,
},
Expand All @@ -51,7 +51,7 @@ func TestPublishRealTimeTidalData(t *testing.T) {

func TestPublishTidalPredictions(t *testing.T) {
var publishedSubject string
var publishedData api.TidePredicted
var publishedData tides.TidePredicted

var tidalPredictions = func(when time.Time) ([]observatory.TidalData, error) {
return []observatory.TidalData{
Expand All @@ -72,14 +72,14 @@ func TestPublishTidalPredictions(t *testing.T) {
service := New(nilData, tidalPredictions, publisher)
service.PublishTidalPredictions(time.Unix(10000, 0))

expectedData := api.TidePredicted{
Timestamp: &timestamp.Timestamp{
expectedData := tides.TidePredicted{
Time: &timestamp.Timestamp{
Seconds: 10000,
Nanos: 0,
},
Predictions: []*api.TidePredicted_Prediction{
&api.TidePredicted_Prediction{
Timestamp: &timestamp.Timestamp{
Predictions: []*tides.TidePredicted_Prediction{
&tides.TidePredicted_Prediction{
Time: &timestamp.Timestamp{
Seconds: 15000,
Nanos: 0,
},
Expand Down

0 comments on commit b4627c2

Please sign in to comment.