Skip to content

Commit

Permalink
feat: created .protobuf file
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Jan 12, 2019
1 parent b2780d3 commit adcd59b
Show file tree
Hide file tree
Showing 7 changed files with 528 additions and 376 deletions.
Empty file added .generated
Empty file.
98 changes: 85 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,97 @@
SOURCE := $(shell find . -name "*.go")
##
## functions
##

rwildcard = $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))

install:
go install ./cmd/calc-www
##
## vars
##

GOPATH ?= $(HOME)/go
BIN = $(GOPATH)/bin/calcbiz
SOURCES = $(call rwildcard, ./, *.go)
OUR_SOURCES = $(filter-out $(call rwildcard,vendor//,*.go),$(SOURCES))
PROTOS = $(call rwildcard, ./, *.proto)
OUR_PROTOS = $(filter-out $(call rwildcard,vendor//,*.proto),$(PROTOS))
GENERATED_FILES = \
$(patsubst %.proto,%.pb.go,$(PROTOS)) \
$(call rwildcard ./, *.gen.go)
PROTOC_OPTS = -I/protobuf:vendor:.
RUN_OPTS ?=

run: up
##
## rules
##

up:
docker-compose up -d --force-recreate --remove-orphans
.PHONY: help
help:
@echo "Make commands:"
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: \
'/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | \
sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | grep -v / | \
sed 's/^/ $(HELP_MSG_PREFIX)make /'

.PHONY: dev
dev: install
calc-www server
.PHONY: run
run: $(BIN)
$(BIN) server $(RUN_OPTS)

.PHONY: install
install: $(BIN)
$(BIN): .generated $(OUR_SOURCES)
go install -v .

.PHONY: docker
docker:
docker build -t ultreme/calcbiz .
.PHONY: clean
clean:
rm -f $(GENERATED_FILES) .generated

.PHONY: _ci_prepare
_ci_prepare:
touch $(OUR_PROTOS) $(GENERATED_FILES)
sleep 1
touch .generated

.PHONY: generate
generate: .generated
.generated: $(OUR_PROTOS)
rm -f $(GENERATED_FILES)
go mod vendor
docker run \
--user="$(shell id -u)" \
--volume="$(PWD):/go/src/ultre.me/calcbiz" \
--workdir="/go/src/ultre.me/calcbiz" \
--entrypoint="sh" \
--rm \
pathwar/protoc:v1 \
-xec "make _generate"
touch $@

.PHONY: _generate
_generate: $(GENERATED_FILES)

.PHONY: test
test:
test: .generated
go test -v ./...

%.pb.go: %.proto
protoc \
$(PROTOC_OPTS) \
--grpc-gateway_out=logtostderr=true:"$(GOPATH)/src" \
--gogofaster_out=plugins=grpc:"$(GOPATH)/src" \
"$(dir $<)"/*.proto

.PHONY: lint
lint:
golangci-lint run --verbose ./...

##
## production
##

.PHONY: docker.up
docker.up:
docker-compose up -d --force-recreate --remove-orphans

.PHONY: docker.build
docker.build:
docker build -t ultreme/calcbiz .
83 changes: 83 additions & 0 deletions api/api.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
syntax = "proto3";

package calcbiz.server;

import "google/api/annotations.proto";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
//import "google/protobuf/timestamp.proto";

option go_package = "calcbiz.pw/server";
option (gogoproto.sizer_all) = true;
option (gogoproto.marshaler_all) = true;
option (gogoproto.unmarshaler_all) = true;

service Server {
rpc KryptosEncrypt(KryptosInput) returns (KryptosOutput) {
option (google.api.http) = {
post: "/kryptos/encrypt"
body: "*"
};
};
rpc KryptosDecrypt(KryptosInput) returns (KryptosOutput) {
option (google.api.http) = {
post: "/kryptos/encrypt"
body: "*"
};
};
rpc TpyoEnocde(TpyoEnocdeIpunt) returns (TpyoEnocdeOuptut) {
option (google.api.http) = {
post: "/spreadshirt/all"
body: "*"
}; }

rpc Ping(Void) returns (Void) { option (google.api.http) = { get: "/ping" }; };
rpc Dashboard(Void) returns (DashboardOutput) { option (google.api.http) = {get: "/dashboard"}; }
rpc Crew(Void) returns (CrewOutput) { option (google.api.http) = {get: "/crew"}; }
rpc Numberinfo(NumberinfoInput) returns (NumberinfoOutput) { option (google.api.http) = {get: "/numberinfo/{number}"}; }
rpc Recettator(RecettatorInput) returns (RecettatorOutput) { option (google.api.http) = {get: "/recettator/{seed}"}; }
rpc Moijaime(Void) returns (MoijaimeOutput) { option (google.api.http) = {get: "/moijaime"}; }
rpc SpreadshirtRandom(Void) returns (SpreadshirtRandomOutput) { option (google.api.http) = {get: "/spreadshirt/random"}; }
rpc SpreadshirtAll(Void) returns (SpreadshirtAllOutput) { option (google.api.http) = {get: "/spreadshirt/all"}; }
rpc Wotd(Void) returns (WotdOutput) { option (google.api.http) = {get: "/wotd"}; }
rpc AlternateLogo(Void) returns (AlternateLogoOutput) { option (google.api.http) = {get: "/alternate-logo"}; }
rpc SoundcloudMe(Void) returns (SoundcloudMeOutput) { option (google.api.http) = {get: "/soundcloud/me"}; }
rpc SoundcloudPlaylists(Void) returns (SoundcloudPlaylistsOutput) { option (google.api.http) = {get: "/soundcloud/playlists"}; }
rpc SoundcloudPlaylist(SoundcloudPlaylistInput) returns (SoundcloudPlaylistOutput) { option (google.api.http) = {get: "/soundcloud/playlists/{playlist_id}"}; }
rpc SoundcloudTracks(Void) returns (SoundcloudTracksOutput) { option (google.api.http) = {get: "/soundcloud/tracks"}; }
rpc SoundcloudTrack(SoundcloudTrackInput) returns (SoundcloudTrackOutput) { option (google.api.http) = {get: "/soundcloud/tracks/{track_id}"}; }

// SoundcloudAlbums
// Airtable...
// Amuse...
// Distrokid...
// Apple...
// Musicbrainz...
// Genius...
}

message Void {}

message CrewOutput { /* TODO */ }
message KryptosInput { string from = 1; }
message KryptosOutput { string to = 1; }
message TpyoEnocdeIpunt { string from = 1; }
message TpyoEnocdeOuptut { string to = 1; }
message DahsboardRandomOutput { /* TODO */ }
message NumberinfoInput { string number = 1; }
message NumberinfoOutput { /* TODO */ }
message MoijaimeOutput { repeated string kiffs = 1; }
message WotdOutput { string word = 1; }
message AlternateLogoOutput { string path = 1; }
message DahsboardOutput { /* TODO */ }
message RecettatorInput { int64 seed = 1; }
message RecettatorOutput { /* TODO */ }
message DashboardOutput { /* TODO */ }
message SpreadshirtRandomOutput { /* TODO */ }
message SpreadshirtAllOutput { /* TODO */ }
message SoundcloudMeOutput { /* TODO */ }
message SoundcloudPlaylistsOutput { /* TODO */ }
message SoundcloudPlaylistOutput { /* TODO */ }
message SoundcloudTracksOutput { /* TODO */ }
message SoundcloudTrackOutput { /* TODO */ }
message SoundcloudPlaylistInput { string playlist_id = 1; }
message SoundcloudTrackInput { string track_id = 1; }
4 changes: 0 additions & 4 deletions calc.go

This file was deleted.

Loading

0 comments on commit adcd59b

Please sign in to comment.