Move accountant to it's own deployment using gRCP

This commit is contained in:
Marc Di Luzio 2020-06-10 23:23:09 +01:00
parent 8f25f55658
commit 99da6c5d67
14 changed files with 868 additions and 64 deletions

View file

@ -8,6 +8,9 @@ install:
go mod download
go install -ldflags="-X 'github.com/mdiluz/rove/pkg/version.Version=${VERSION}'" ./...
gen:
protoc --proto_path pkg/accounts --go_out=plugins=grpc:pkg/accounts/ --go_opt=paths=source_relative pkg/accounts/accounts.proto
test:
go mod download
go build ./...

View file

@ -0,0 +1,11 @@
FROM golang:latest
LABEL maintainer="Marc Di Luzio <marc.diluzio@gmail.com>"
WORKDIR /app
COPY . .
RUN go mod download
RUN go build -o rove-accountant -ldflags="-X 'github.com/mdiluz/rove/pkg/version.Version=$(git describe --always --long --dirty --tags)'" cmd/rove-accountant/main.go
CMD [ "./rove-accountant" ]

View file

@ -1,4 +1,4 @@
package accounts
package internal
import (
"fmt"
@ -36,6 +36,7 @@ func (a *Accountant) RegisterAccount(name string) (acc Account, err error) {
// Set the account name
acc.Name = name
acc.Data = make(map[string]string)
// Verify this acount isn't already registered
for _, a := range a.Accounts {
@ -65,7 +66,7 @@ func (a *Accountant) AssignData(account string, key string, value string) error
}
// GetRover gets the rover rover for the account
func (a *Accountant) GetData(account string, key string) (string, error) {
func (a *Accountant) GetValue(account string, key string) (string, error) {
// Find the account matching the ID
if this, ok := a.Accounts[account]; !ok {
return "", fmt.Errorf("no account found for id: %s", account)

View file

@ -1,4 +1,4 @@
package accounts
package internal
import (
"testing"
@ -58,7 +58,7 @@ func TestAccountant_AssignGetData(t *testing.T) {
err = accountant.AssignData(a.Name, "key", "value")
if err != nil {
t.Error("Failed to set data for created account")
} else if id, err := accountant.GetData(a.Name, "key"); err != nil {
} else if id, err := accountant.GetValue(a.Name, "key"); err != nil {
t.Error("Failed to get data for account")
} else if id != "value" {
t.Error("Fetched data is incorrect for account")

130
cmd/rove-accountant/main.go Normal file
View file

@ -0,0 +1,130 @@
package main
import (
"context"
"flag"
"fmt"
"log"
"net"
"os"
"os/signal"
"sync"
"syscall"
"github.com/mdiluz/rove/cmd/rove-accountant/internal"
"github.com/mdiluz/rove/pkg/accounts"
"github.com/mdiluz/rove/pkg/persistence"
"google.golang.org/grpc"
)
var address = flag.String("address", "", "port to server the accountant on")
var data = flag.String("data", os.TempDir(), "path to persistent data")
// accountantServer is the internal object to manage the requests
type accountantServer struct {
accountant *internal.Accountant
sync sync.RWMutex
}
// Register will register an account
func (a *accountantServer) Register(ctx context.Context, in *accounts.RegisterInfo) (*accounts.RegisterResponse, error) {
a.sync.Lock()
defer a.sync.Unlock()
// Try and register the account itself
fmt.Printf("Registering account: %s\n", in.Name)
if _, err := a.accountant.RegisterAccount(in.Name); err != nil {
fmt.Printf("Error: %s\n", err)
return &accounts.RegisterResponse{Success: false, Error: fmt.Sprintf("error registering account: %s", err)}, nil
}
// Save out the accounts
if err := persistence.Save("accounts", a.accountant); err != nil {
fmt.Printf("Error: %s\n", err)
return &accounts.RegisterResponse{Success: false, Error: fmt.Sprintf("failed to save accounts: %s", err)}, nil
}
return &accounts.RegisterResponse{Success: true}, nil
}
// AssignData assigns a key value pair to an account
func (a *accountantServer) AssignValue(_ context.Context, in *accounts.DataKeyValue) (*accounts.Response, error) {
a.sync.RLock()
defer a.sync.RUnlock()
// Try and assign the data
fmt.Printf("Assigning value for account %s: %s->%s\n", in.Account, in.Key, in.Value)
err := a.accountant.AssignData(in.Account, in.Key, in.Value)
if err != nil {
fmt.Printf("Error: %s\n", err)
return &accounts.Response{Success: false, Error: err.Error()}, nil
}
return &accounts.Response{Success: true}, nil
}
// GetData gets the value for a key
func (a *accountantServer) GetValue(_ context.Context, in *accounts.DataKey) (*accounts.DataResponse, error) {
a.sync.RLock()
defer a.sync.RUnlock()
// Try and fetch the rover
fmt.Printf("Getting value for account %s: %s\n", in.Account, in.Key)
data, err := a.accountant.GetValue(in.Account, in.Key)
if err != nil {
fmt.Printf("Error: %s\n", err)
return &accounts.DataResponse{Success: false, Error: err.Error()}, nil
}
return &accounts.DataResponse{Success: true, Value: data}, nil
}
// main
func main() {
flag.Parse()
// Verify the input
if len(*address) == 0 {
log.Fatal("No address set with --address")
}
persistence.SetPath(*data)
// Initialise and load the accountant
accountant := &internal.Accountant{}
if err := persistence.Load("accounts", accountant); err != nil {
log.Fatalf("failed to load account data: %s", err)
}
// Set up the RPC server and register
lis, err := net.Listen("tcp", *address)
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
grpcServer := grpc.NewServer()
accounts.RegisterAccountantServer(grpcServer, &accountantServer{
accountant: accountant,
})
// Set up the close handler
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
fmt.Println("Quit requested, exiting...")
grpcServer.Stop()
}()
// Serve the RPC server
fmt.Printf("Serving accountant on %s\n", *address)
if err := grpcServer.Serve(lis); err != nil {
log.Fatalf("failed to server gRPC: %s", err)
}
// Save out the accountant data
if err := persistence.Save("accounts", accountant); err != nil {
log.Fatalf("failed to save accounts: %s", err)
}
}

View file

@ -1,12 +1,14 @@
package internal
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"github.com/google/uuid"
"github.com/mdiluz/rove/pkg/accounts"
"github.com/mdiluz/rove/pkg/rove"
"github.com/mdiluz/rove/pkg/version"
)
@ -84,14 +86,19 @@ func HandleRegister(s *Server, vars map[string]string, b io.ReadCloser, w io.Wri
} else if len(data.Name) == 0 {
response.Error = "Cannot register empty name"
} else if acc, err := s.accountant.RegisterAccount(data.Name); err != nil {
}
reg := accounts.RegisterInfo{Name: data.Name}
if acc, err := s.accountant.Register(context.Background(), &reg); err != nil {
response.Error = err.Error()
} else if _, _, err := s.SpawnRoverForAccount(acc.Name); err != nil {
} else if !acc.Success {
response.Error = acc.Error
} else if _, _, err := s.SpawnRoverForAccount(data.Name); err != nil {
response.Error = err.Error()
} else if err := s.SaveAll(); err != nil {
response.Error = fmt.Sprintf("Internal server error when saving: %s", err)
} else if err := s.SaveWorld(); err != nil {
response.Error = fmt.Sprintf("Internal server error when saving world: %s", err)
} else {
// Save out the new accounts
@ -116,13 +123,19 @@ func HandleCommand(s *Server, vars map[string]string, b io.ReadCloser, w io.Writ
fmt.Printf("Failed to decode json: %s\n", err)
response.Error = err.Error()
} else if len(id) == 0 {
}
key := accounts.DataKey{Account: id, Key: "rover"}
if len(id) == 0 {
response.Error = "No account ID provided"
} else if inst, err := s.accountant.GetData(id, "rover"); err != nil {
} else if resp, err := s.accountant.GetValue(context.Background(), &key); err != nil {
response.Error = fmt.Sprintf("Provided account has no rover: %s", err)
} else if id, err := uuid.Parse(inst); err != nil {
} else if !resp.Success {
response.Error = resp.Error
} else if id, err := uuid.Parse(resp.Value); err != nil {
response.Error = fmt.Sprintf("Account had invalid rover id: %s", err)
} else if err := s.world.Enqueue(id, data.Commands...); err != nil {
@ -143,13 +156,17 @@ func HandleRadar(s *Server, vars map[string]string, b io.ReadCloser, w io.Writer
}
id := vars["account"]
key := accounts.DataKey{Account: id, Key: "rover"}
if len(id) == 0 {
response.Error = "No account ID provided"
} else if inst, err := s.accountant.GetData(id, "rover"); err != nil {
} else if resp, err := s.accountant.GetValue(context.Background(), &key); err != nil {
response.Error = fmt.Sprintf("Provided account has no rover: %s", err)
} else if id, err := uuid.Parse(inst); err != nil {
} else if !resp.Success {
response.Error = resp.Error
} else if id, err := uuid.Parse(resp.Value); err != nil {
response.Error = fmt.Sprintf("Account had invalid rover id: %s", err)
} else if attrib, err := s.world.RoverAttributes(id); err != nil {
@ -175,13 +192,17 @@ func HandleRover(s *Server, vars map[string]string, b io.ReadCloser, w io.Writer
}
id := vars["account"]
key := accounts.DataKey{Account: id, Key: "rover"}
if len(id) == 0 {
response.Error = "No account ID provided"
} else if inst, err := s.accountant.GetData(id, "rover"); err != nil {
} else if resp, err := s.accountant.GetValue(context.Background(), &key); err != nil {
response.Error = fmt.Sprintf("Provided account has no rover: %s", err)
} else if id, err := uuid.Parse(inst); err != nil {
} else if !resp.Success {
response.Error = resp.Error
} else if id, err := uuid.Parse(resp.Value); err != nil {
response.Error = fmt.Sprintf("Account had invalid rover id: %s", err)
} else if attribs, err := s.world.RoverAttributes(id); err != nil {

View file

@ -2,12 +2,14 @@ package internal
import (
"bytes"
"context"
"encoding/json"
"net/http"
"net/http/httptest"
"path"
"testing"
"github.com/mdiluz/rove/pkg/accounts"
"github.com/mdiluz/rove/pkg/game"
"github.com/mdiluz/rove/pkg/rove"
"github.com/mdiluz/rove/pkg/vector"
@ -62,11 +64,15 @@ func TestHandleRegister(t *testing.T) {
func TestHandleCommand(t *testing.T) {
s := NewServer()
s.Initialise(false) // Leave the world empty with no obstacles
a, err := s.accountant.RegisterAccount("test")
reg := accounts.RegisterInfo{Name: "test"}
acc, err := s.accountant.Register(context.Background(), &reg)
assert.NoError(t, err)
assert.True(t, acc.Success)
assert.NoError(t, err, "Error registering account")
// Spawn the rover rover for the account
_, inst, err := s.SpawnRoverForAccount(a.Name)
_, inst, err := s.SpawnRoverForAccount("test")
assert.NoError(t, s.world.WarpRover(inst, vector.Vector{}))
attribs, err := s.world.RoverAttributes(inst)
@ -85,7 +91,7 @@ func TestHandleCommand(t *testing.T) {
b, err := json.Marshal(data)
assert.NoError(t, err, "Error marshalling data")
request, _ := http.NewRequest(http.MethodPost, path.Join("/", a.Name, "/command"), bytes.NewReader(b))
request, _ := http.NewRequest(http.MethodPost, path.Join("/", "test", "/command"), bytes.NewReader(b))
response := httptest.NewRecorder()
s.router.ServeHTTP(response, request)
@ -114,11 +120,14 @@ func TestHandleCommand(t *testing.T) {
func TestHandleRadar(t *testing.T) {
s := NewServer()
s.Initialise(false) // Spawn a clean world
a, err := s.accountant.RegisterAccount("test")
reg := accounts.RegisterInfo{Name: "test"}
acc, err := s.accountant.Register(context.Background(), &reg)
assert.NoError(t, err)
assert.True(t, acc.Success)
assert.NoError(t, err, "Error registering account")
// Spawn the rover rover for the account
attrib, id, err := s.SpawnRoverForAccount(a.Name)
attrib, id, err := s.SpawnRoverForAccount("test")
assert.NoError(t, err)
// Warp this rover to 0,0
@ -134,7 +143,7 @@ func TestHandleRadar(t *testing.T) {
assert.NoError(t, s.world.Atlas.SetTile(rockPos, game.TileRock))
assert.NoError(t, s.world.Atlas.SetTile(emptyPos, game.TileEmpty))
request, _ := http.NewRequest(http.MethodGet, path.Join("/", a.Name, "/radar"), nil)
request, _ := http.NewRequest(http.MethodGet, path.Join("/", "test", "/radar"), nil)
response := httptest.NewRecorder()
s.router.ServeHTTP(response, request)
@ -168,14 +177,16 @@ func TestHandleRadar(t *testing.T) {
func TestHandleRover(t *testing.T) {
s := NewServer()
s.Initialise(true)
a, err := s.accountant.RegisterAccount("test")
assert.NoError(t, err, "Error registering account")
reg := accounts.RegisterInfo{Name: "test"}
acc, err := s.accountant.Register(context.Background(), &reg)
assert.NoError(t, err)
assert.True(t, acc.Success)
// Spawn one rover for the account
attribs, _, err := s.SpawnRoverForAccount(a.Name)
attribs, _, err := s.SpawnRoverForAccount("test")
assert.NoError(t, err)
request, _ := http.NewRequest(http.MethodGet, path.Join("/", a.Name, "/rover"), nil)
request, _ := http.NewRequest(http.MethodGet, path.Join("/", "test", "/rover"), nil)
response := httptest.NewRecorder()
s.router.ServeHTTP(response, request)

View file

@ -3,6 +3,7 @@ package internal
import (
"context"
"encoding/json"
"flag"
"fmt"
"log"
"net"
@ -16,8 +17,11 @@ import (
"github.com/mdiluz/rove/pkg/game"
"github.com/mdiluz/rove/pkg/persistence"
"github.com/robfig/cron"
"google.golang.org/grpc"
)
var accountantAddress = flag.String("accountant", "", "address of the accountant to connect to")
const (
// PersistentData will allow the server to load and save it's state
PersistentData = iota
@ -30,8 +34,11 @@ const (
type Server struct {
// Internal state
accountant *accounts.Accountant
world *game.World
world *game.World
// Accountant server
accountant accounts.AccountantClient
clientConn *grpc.ClientConn
// HTTP server
listener net.Listener
@ -96,9 +103,6 @@ func NewServer(opts ...ServerOption) *Server {
// Set up the server object
s.server = &http.Server{Addr: s.address, Handler: s.router}
// Create the accountant
s.accountant = accounts.NewAccountant()
// Start small, we can grow the world later
s.world = game.NewWorld(4, 8)
@ -111,13 +115,21 @@ func (s *Server) Initialise(fillWorld bool) (err error) {
// Add to our sync
s.sync.Add(1)
// Connect to the accountant
fmt.Printf("Dialing accountant on %s\n", *accountantAddress)
clientConn, err := grpc.Dial(*accountantAddress, grpc.WithInsecure())
if err != nil {
return err
}
s.accountant = accounts.NewAccountantClient(clientConn)
// Spawn a border on the default world
if err := s.world.SpawnWorld(fillWorld); err != nil {
return err
}
// Load the accounts if requested
if err := s.LoadAll(); err != nil {
// Load the world file
if err := s.LoadWorld(); err != nil {
return err
}
@ -183,6 +195,11 @@ func (s *Server) Stop() error {
return err
}
// Close the accountant connection
if err := s.clientConn.Close(); err != nil {
return err
}
return nil
}
@ -192,7 +209,7 @@ func (s *Server) Close() error {
s.sync.Wait()
// Save and return
return s.SaveAll()
return s.SaveWorld()
}
// Close waits until the server is finished and closes up shop
@ -218,36 +235,12 @@ func (s *Server) SaveWorld() error {
return nil
}
// SaveAccounts will save out the accounts file
func (s *Server) SaveAccounts() error {
if s.persistence == PersistentData {
if err := persistence.SaveAll("accounts", s.accountant); err != nil {
return fmt.Errorf("failed to save out persistent data: %s", err)
}
}
return nil
}
// SaveAll will save out all server files
func (s *Server) SaveAll() error {
// Save the accounts if requested
if s.persistence == PersistentData {
s.world.RLock()
defer s.world.RUnlock()
if err := persistence.SaveAll("accounts", s.accountant, "world", s.world); err != nil {
return err
}
}
return nil
}
// LoadAll will load all persistent data
func (s *Server) LoadAll() error {
// LoadWorld will load all persistent data
func (s *Server) LoadWorld() error {
if s.persistence == PersistentData {
s.world.Lock()
defer s.world.Unlock()
if err := persistence.LoadAll("accounts", &s.accountant, "world", &s.world); err != nil {
if err := persistence.LoadAll("world", &s.world); err != nil {
return err
}
}
@ -289,7 +282,11 @@ func (s *Server) SpawnRoverForAccount(account string) (game.RoverAttributes, uui
return game.RoverAttributes{}, uuid.UUID{}, fmt.Errorf("No attributes found for created rover: %s", err)
} else {
if err := s.accountant.AssignData(account, "rover", inst.String()); err != nil {
keyval := accounts.DataKeyValue{Account: account, Key: "rover", Value: inst.String()}
resp, err := s.accountant.AssignValue(context.Background(), &keyval)
if err != nil || !resp.Success {
fmt.Printf("Failed to assign rover to account, %s, %s", err, resp.Error)
// Try and clear up the rover
if err := s.world.DestroyRover(inst); err != nil {
fmt.Printf("Failed to destroy rover after failed rover assign: %s", err)

View file

@ -113,6 +113,9 @@ func InnerMain(command string) error {
}
case "register":
if len(*name) == 0 {
return fmt.Errorf("must set name with -name")
}
d := rove.RegisterData{
Name: *name,
}
@ -125,8 +128,8 @@ func InnerMain(command string) error {
return fmt.Errorf("Server returned failure: %s", response.Error)
default:
fmt.Printf("Registered account with id: %s\n", d.Name)
config.Accounts[config.Host] = d.Name
fmt.Printf("Registered account with id: %s\n", *name)
config.Accounts[config.Host] = *name
}
case "move":

View file

@ -11,6 +11,17 @@ services:
image: rove-server:latest
ports:
- "80:80"
command: ./rove-server --address ":80" --data=/mnt/rove-server ${ROVE_ARGS}
command: ./rove-server --address ":80" --data=/mnt/rove-server ${ROVE_ARGS} --accountant "rove-accountant:8081"
volumes:
- persistent-data:/mnt/rove-server:rw
rove-accountant:
build:
context: .
dockerfile: cmd/rove-accountant/Dockerfile
image: rove-accountant:latest
ports:
- "8081:8081"
command: ./rove-accountant --address ":8081" --data=/mnt/rove-server
volumes:
- persistent-data:/mnt/rove-server:rw

2
go.mod
View file

@ -3,9 +3,11 @@ module github.com/mdiluz/rove
go 1.14
require (
github.com/golang/protobuf v1.4.2
github.com/google/uuid v1.1.1
github.com/gorilla/mux v1.7.4
github.com/robfig/cron v1.2.0
github.com/stretchr/testify v1.6.0
github.com/tjarratt/babble v0.0.0-20191209142150-eecdf8c2339d
google.golang.org/grpc v1.29.1
)

68
go.sum
View file

@ -1,11 +1,36 @@
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/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
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/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
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.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc=
github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ=
github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@ -13,6 +38,49 @@ github.com/stretchr/testify v1.6.0 h1:jlIyCplCJFULU/01vCkhKuTyc3OorI3bJFuw6obfgh
github.com/stretchr/testify v1.6.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tjarratt/babble v0.0.0-20191209142150-eecdf8c2339d h1:b7oHBI6TgTdCDuqTijsVldzlh+6cfQpdYLz1EKtCAoY=
github.com/tjarratt/babble v0.0.0-20191209142150-eecdf8c2339d/go.mod h1:O5hBrCGqzfb+8WyY8ico2AyQau7XQwAfEQeEQ5/5V9E=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/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-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
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-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
google.golang.org/grpc v1.29.1 h1:EC2SB8S04d2r73uptxphDSUG+kTKVgjRPF+N3xpxRB4=
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

503
pkg/accounts/accounts.pb.go Normal file
View file

@ -0,0 +1,503 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: accounts.proto
package accounts
import (
context "context"
fmt "fmt"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type RegisterInfo struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *RegisterInfo) Reset() { *m = RegisterInfo{} }
func (m *RegisterInfo) String() string { return proto.CompactTextString(m) }
func (*RegisterInfo) ProtoMessage() {}
func (*RegisterInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_e1e7723af4c007b7, []int{0}
}
func (m *RegisterInfo) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_RegisterInfo.Unmarshal(m, b)
}
func (m *RegisterInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_RegisterInfo.Marshal(b, m, deterministic)
}
func (m *RegisterInfo) XXX_Merge(src proto.Message) {
xxx_messageInfo_RegisterInfo.Merge(m, src)
}
func (m *RegisterInfo) XXX_Size() int {
return xxx_messageInfo_RegisterInfo.Size(m)
}
func (m *RegisterInfo) XXX_DiscardUnknown() {
xxx_messageInfo_RegisterInfo.DiscardUnknown(m)
}
var xxx_messageInfo_RegisterInfo proto.InternalMessageInfo
func (m *RegisterInfo) GetName() string {
if m != nil {
return m.Name
}
return ""
}
type RegisterResponse struct {
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *RegisterResponse) Reset() { *m = RegisterResponse{} }
func (m *RegisterResponse) String() string { return proto.CompactTextString(m) }
func (*RegisterResponse) ProtoMessage() {}
func (*RegisterResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_e1e7723af4c007b7, []int{1}
}
func (m *RegisterResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_RegisterResponse.Unmarshal(m, b)
}
func (m *RegisterResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_RegisterResponse.Marshal(b, m, deterministic)
}
func (m *RegisterResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_RegisterResponse.Merge(m, src)
}
func (m *RegisterResponse) XXX_Size() int {
return xxx_messageInfo_RegisterResponse.Size(m)
}
func (m *RegisterResponse) XXX_DiscardUnknown() {
xxx_messageInfo_RegisterResponse.DiscardUnknown(m)
}
var xxx_messageInfo_RegisterResponse proto.InternalMessageInfo
func (m *RegisterResponse) GetSuccess() bool {
if m != nil {
return m.Success
}
return false
}
func (m *RegisterResponse) GetError() string {
if m != nil {
return m.Error
}
return ""
}
type DataKeyValue struct {
Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"`
Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *DataKeyValue) Reset() { *m = DataKeyValue{} }
func (m *DataKeyValue) String() string { return proto.CompactTextString(m) }
func (*DataKeyValue) ProtoMessage() {}
func (*DataKeyValue) Descriptor() ([]byte, []int) {
return fileDescriptor_e1e7723af4c007b7, []int{2}
}
func (m *DataKeyValue) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DataKeyValue.Unmarshal(m, b)
}
func (m *DataKeyValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_DataKeyValue.Marshal(b, m, deterministic)
}
func (m *DataKeyValue) XXX_Merge(src proto.Message) {
xxx_messageInfo_DataKeyValue.Merge(m, src)
}
func (m *DataKeyValue) XXX_Size() int {
return xxx_messageInfo_DataKeyValue.Size(m)
}
func (m *DataKeyValue) XXX_DiscardUnknown() {
xxx_messageInfo_DataKeyValue.DiscardUnknown(m)
}
var xxx_messageInfo_DataKeyValue proto.InternalMessageInfo
func (m *DataKeyValue) GetAccount() string {
if m != nil {
return m.Account
}
return ""
}
func (m *DataKeyValue) GetKey() string {
if m != nil {
return m.Key
}
return ""
}
func (m *DataKeyValue) GetValue() string {
if m != nil {
return m.Value
}
return ""
}
type Response struct {
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Response) Reset() { *m = Response{} }
func (m *Response) String() string { return proto.CompactTextString(m) }
func (*Response) ProtoMessage() {}
func (*Response) Descriptor() ([]byte, []int) {
return fileDescriptor_e1e7723af4c007b7, []int{3}
}
func (m *Response) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Response.Unmarshal(m, b)
}
func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Response.Marshal(b, m, deterministic)
}
func (m *Response) XXX_Merge(src proto.Message) {
xxx_messageInfo_Response.Merge(m, src)
}
func (m *Response) XXX_Size() int {
return xxx_messageInfo_Response.Size(m)
}
func (m *Response) XXX_DiscardUnknown() {
xxx_messageInfo_Response.DiscardUnknown(m)
}
var xxx_messageInfo_Response proto.InternalMessageInfo
func (m *Response) GetSuccess() bool {
if m != nil {
return m.Success
}
return false
}
func (m *Response) GetError() string {
if m != nil {
return m.Error
}
return ""
}
type DataKey struct {
Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"`
Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *DataKey) Reset() { *m = DataKey{} }
func (m *DataKey) String() string { return proto.CompactTextString(m) }
func (*DataKey) ProtoMessage() {}
func (*DataKey) Descriptor() ([]byte, []int) {
return fileDescriptor_e1e7723af4c007b7, []int{4}
}
func (m *DataKey) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DataKey.Unmarshal(m, b)
}
func (m *DataKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_DataKey.Marshal(b, m, deterministic)
}
func (m *DataKey) XXX_Merge(src proto.Message) {
xxx_messageInfo_DataKey.Merge(m, src)
}
func (m *DataKey) XXX_Size() int {
return xxx_messageInfo_DataKey.Size(m)
}
func (m *DataKey) XXX_DiscardUnknown() {
xxx_messageInfo_DataKey.DiscardUnknown(m)
}
var xxx_messageInfo_DataKey proto.InternalMessageInfo
func (m *DataKey) GetAccount() string {
if m != nil {
return m.Account
}
return ""
}
func (m *DataKey) GetKey() string {
if m != nil {
return m.Key
}
return ""
}
type DataResponse struct {
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *DataResponse) Reset() { *m = DataResponse{} }
func (m *DataResponse) String() string { return proto.CompactTextString(m) }
func (*DataResponse) ProtoMessage() {}
func (*DataResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_e1e7723af4c007b7, []int{5}
}
func (m *DataResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DataResponse.Unmarshal(m, b)
}
func (m *DataResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_DataResponse.Marshal(b, m, deterministic)
}
func (m *DataResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_DataResponse.Merge(m, src)
}
func (m *DataResponse) XXX_Size() int {
return xxx_messageInfo_DataResponse.Size(m)
}
func (m *DataResponse) XXX_DiscardUnknown() {
xxx_messageInfo_DataResponse.DiscardUnknown(m)
}
var xxx_messageInfo_DataResponse proto.InternalMessageInfo
func (m *DataResponse) GetSuccess() bool {
if m != nil {
return m.Success
}
return false
}
func (m *DataResponse) GetError() string {
if m != nil {
return m.Error
}
return ""
}
func (m *DataResponse) GetValue() string {
if m != nil {
return m.Value
}
return ""
}
func init() {
proto.RegisterType((*RegisterInfo)(nil), "accounts.RegisterInfo")
proto.RegisterType((*RegisterResponse)(nil), "accounts.RegisterResponse")
proto.RegisterType((*DataKeyValue)(nil), "accounts.DataKeyValue")
proto.RegisterType((*Response)(nil), "accounts.Response")
proto.RegisterType((*DataKey)(nil), "accounts.DataKey")
proto.RegisterType((*DataResponse)(nil), "accounts.DataResponse")
}
func init() {
proto.RegisterFile("accounts.proto", fileDescriptor_e1e7723af4c007b7)
}
var fileDescriptor_e1e7723af4c007b7 = []byte{
// 298 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x4f, 0x4b, 0xc3, 0x40,
0x10, 0xc5, 0x8d, 0x55, 0x1b, 0xc7, 0x22, 0x75, 0x11, 0x09, 0x39, 0xc9, 0x8a, 0xe0, 0x29, 0x01,
0x45, 0x04, 0xbd, 0xd8, 0x22, 0x88, 0x78, 0x91, 0x20, 0x1e, 0xbc, 0x6d, 0xe3, 0x18, 0x43, 0x9b,
0xdd, 0xb0, 0x7f, 0x0a, 0xf5, 0xf3, 0xf9, 0xc1, 0x24, 0xbb, 0xd9, 0x1a, 0xac, 0x17, 0x7b, 0xdb,
0x17, 0xe6, 0xf7, 0xe6, 0xcd, 0x4c, 0x60, 0x9f, 0xe5, 0xb9, 0x30, 0x5c, 0xab, 0xa4, 0x96, 0x42,
0x0b, 0x12, 0x7a, 0x4d, 0x29, 0x0c, 0x32, 0x2c, 0x4a, 0xa5, 0x51, 0x3e, 0xf0, 0x77, 0x41, 0x08,
0x6c, 0x71, 0x56, 0x61, 0x14, 0x1c, 0x07, 0x67, 0xbb, 0x99, 0x7d, 0xd3, 0x31, 0x0c, 0x7d, 0x4d,
0x86, 0xaa, 0x16, 0x5c, 0x21, 0x89, 0xa0, 0xaf, 0x4c, 0x9e, 0xa3, 0x52, 0xb6, 0x34, 0xcc, 0xbc,
0x24, 0x87, 0xb0, 0x8d, 0x52, 0x0a, 0x19, 0x6d, 0x5a, 0x0b, 0x27, 0xe8, 0x13, 0x0c, 0xee, 0x98,
0x66, 0x8f, 0xb8, 0x78, 0x61, 0x33, 0x63, 0xf9, 0x36, 0x43, 0xdb, 0xca, 0x4b, 0x32, 0x84, 0xde,
0x14, 0x17, 0x2d, 0xdd, 0x3c, 0x1b, 0xc7, 0x79, 0x03, 0x45, 0x3d, 0xe7, 0x68, 0x05, 0xbd, 0x86,
0x70, 0xed, 0x34, 0x97, 0xd0, 0x6f, 0xd3, 0xfc, 0x27, 0x08, 0x7d, 0x76, 0x43, 0xac, 0xdb, 0xf6,
0xef, 0x41, 0xce, 0xbf, 0x02, 0x80, 0x91, 0xeb, 0xc9, 0xb8, 0x26, 0xb7, 0xcd, 0x5c, 0x6e, 0xdb,
0xe4, 0x28, 0x59, 0x1e, 0xae, 0x7b, 0xa5, 0x38, 0x5e, 0xfd, 0xee, 0x43, 0xd1, 0x0d, 0x72, 0x03,
0x7b, 0x23, 0xa5, 0xca, 0x82, 0xbb, 0x55, 0x77, 0x4c, 0xba, 0x27, 0x88, 0x49, 0xd7, 0x64, 0x09,
0x5f, 0x41, 0x78, 0x8f, 0xda, 0x91, 0x07, 0x2b, 0x64, 0xfc, 0xcb, 0xec, 0x07, 0x1c, 0x9f, 0xbe,
0x9e, 0x14, 0xa5, 0xfe, 0x30, 0x93, 0x24, 0x17, 0x55, 0x5a, 0xbd, 0x95, 0x33, 0xf3, 0x99, 0x4a,
0x31, 0xc7, 0xb4, 0x9e, 0x16, 0xa9, 0xa7, 0x26, 0x3b, 0xf6, 0x0f, 0xbc, 0xf8, 0x0e, 0x00, 0x00,
0xff, 0xff, 0xef, 0x53, 0xc6, 0xba, 0x93, 0x02, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6
// AccountantClient is the client API for Accountant service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type AccountantClient interface {
Register(ctx context.Context, in *RegisterInfo, opts ...grpc.CallOption) (*RegisterResponse, error)
AssignValue(ctx context.Context, in *DataKeyValue, opts ...grpc.CallOption) (*Response, error)
GetValue(ctx context.Context, in *DataKey, opts ...grpc.CallOption) (*DataResponse, error)
}
type accountantClient struct {
cc grpc.ClientConnInterface
}
func NewAccountantClient(cc grpc.ClientConnInterface) AccountantClient {
return &accountantClient{cc}
}
func (c *accountantClient) Register(ctx context.Context, in *RegisterInfo, opts ...grpc.CallOption) (*RegisterResponse, error) {
out := new(RegisterResponse)
err := c.cc.Invoke(ctx, "/accounts.Accountant/Register", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *accountantClient) AssignValue(ctx context.Context, in *DataKeyValue, opts ...grpc.CallOption) (*Response, error) {
out := new(Response)
err := c.cc.Invoke(ctx, "/accounts.Accountant/AssignValue", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *accountantClient) GetValue(ctx context.Context, in *DataKey, opts ...grpc.CallOption) (*DataResponse, error) {
out := new(DataResponse)
err := c.cc.Invoke(ctx, "/accounts.Accountant/GetValue", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// AccountantServer is the server API for Accountant service.
type AccountantServer interface {
Register(context.Context, *RegisterInfo) (*RegisterResponse, error)
AssignValue(context.Context, *DataKeyValue) (*Response, error)
GetValue(context.Context, *DataKey) (*DataResponse, error)
}
// UnimplementedAccountantServer can be embedded to have forward compatible implementations.
type UnimplementedAccountantServer struct {
}
func (*UnimplementedAccountantServer) Register(ctx context.Context, req *RegisterInfo) (*RegisterResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Register not implemented")
}
func (*UnimplementedAccountantServer) AssignValue(ctx context.Context, req *DataKeyValue) (*Response, error) {
return nil, status.Errorf(codes.Unimplemented, "method AssignValue not implemented")
}
func (*UnimplementedAccountantServer) GetValue(ctx context.Context, req *DataKey) (*DataResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetValue not implemented")
}
func RegisterAccountantServer(s *grpc.Server, srv AccountantServer) {
s.RegisterService(&_Accountant_serviceDesc, srv)
}
func _Accountant_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RegisterInfo)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AccountantServer).Register(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/accounts.Accountant/Register",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AccountantServer).Register(ctx, req.(*RegisterInfo))
}
return interceptor(ctx, in, info, handler)
}
func _Accountant_AssignValue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DataKeyValue)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AccountantServer).AssignValue(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/accounts.Accountant/AssignValue",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AccountantServer).AssignValue(ctx, req.(*DataKeyValue))
}
return interceptor(ctx, in, info, handler)
}
func _Accountant_GetValue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DataKey)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AccountantServer).GetValue(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/accounts.Accountant/GetValue",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AccountantServer).GetValue(ctx, req.(*DataKey))
}
return interceptor(ctx, in, info, handler)
}
var _Accountant_serviceDesc = grpc.ServiceDesc{
ServiceName: "accounts.Accountant",
HandlerType: (*AccountantServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Register",
Handler: _Accountant_Register_Handler,
},
{
MethodName: "AssignValue",
Handler: _Accountant_AssignValue_Handler,
},
{
MethodName: "GetValue",
Handler: _Accountant_GetValue_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "accounts.proto",
}

View file

@ -0,0 +1,43 @@
syntax = "proto3";
option go_package = "github.com/mdiluz/rove/pkg/accounts";
package accounts;
service Accountant {
rpc Register(RegisterInfo) returns (RegisterResponse) {}
rpc AssignValue(DataKeyValue) returns (Response) {}
rpc GetValue(DataKey) returns (DataResponse) {}
}
message RegisterInfo {
string name = 1;
}
message RegisterResponse {
bool success = 1;
string error = 2;
}
message DataKeyValue {
string account = 1;
string key = 2;
string value = 3;
}
message Response {
bool success = 1;
string error = 2;
}
message DataKey {
string account = 1;
string key = 2;
}
message DataResponse {
bool success = 1;
string error = 2;
string value = 3;
}