Simplify - remove rove-accountant
This was a fun little gRPC experiment but it's simply not needed
This commit is contained in:
parent
984ff56664
commit
abcebcebb6
12 changed files with 20 additions and 930 deletions
|
@ -7,7 +7,6 @@ RUN go mod download
|
||||||
|
|
||||||
# Build the executables
|
# Build the executables
|
||||||
RUN go build -o rove-server -ldflags="-X 'github.com/mdiluz/rove/pkg/version.Version=$(git describe --always --long --dirty --tags)'" cmd/rove-server/main.go
|
RUN go build -o rove-server -ldflags="-X 'github.com/mdiluz/rove/pkg/version.Version=$(git describe --always --long --dirty --tags)'" cmd/rove-server/main.go
|
||||||
RUN go build -o rove-accountant cmd/rove-accountant/main.go
|
|
||||||
RUN go build -o rove-reverse-proxy cmd/rove-reverse-proxy/main.go
|
RUN go build -o rove-reverse-proxy cmd/rove-reverse-proxy/main.go
|
||||||
|
|
||||||
CMD [ "./rove-server" ]
|
CMD [ "./rove-server" ]
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -9,8 +9,6 @@ install:
|
||||||
go install -ldflags="-X 'github.com/mdiluz/rove/pkg/version.Version=${VERSION}'" ./...
|
go install -ldflags="-X 'github.com/mdiluz/rove/pkg/version.Version=${VERSION}'" ./...
|
||||||
|
|
||||||
gen:
|
gen:
|
||||||
@echo Generating accountant gRPC
|
|
||||||
protoc --proto_path proto --go_out=plugins=grpc:pkg/ --go_opt=paths=source_relative proto/accounts/accounts.proto
|
|
||||||
@echo Generating rove server gRPC
|
@echo Generating rove server gRPC
|
||||||
protoc --proto_path proto --go_out=plugins=grpc:pkg/ --go_opt=paths=source_relative proto/rove/rove.proto
|
protoc --proto_path proto --go_out=plugins=grpc:pkg/ --go_opt=paths=source_relative proto/rove/rove.proto
|
||||||
protoc --proto_path proto --grpc-gateway_out=paths=source_relative:pkg/ proto/rove/rove.proto
|
protoc --proto_path proto --grpc-gateway_out=paths=source_relative:pkg/ proto/rove/rove.proto
|
||||||
|
|
|
@ -1,134 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
"net"
|
|
||||||
"os"
|
|
||||||
"os/signal"
|
|
||||||
"strconv"
|
|
||||||
"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 data = os.Getenv("DATA_PATH")
|
|
||||||
|
|
||||||
// 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
|
|
||||||
log.Printf("Registering account: %s\n", in.Name)
|
|
||||||
if _, err := a.accountant.RegisterAccount(in.Name); err != nil {
|
|
||||||
log.Printf("Error: %s\n", err)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save out the accounts
|
|
||||||
if err := persistence.Save("accounts", a.accountant); err != nil {
|
|
||||||
log.Printf("Error: %s\n", err)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &accounts.RegisterResponse{}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// AssignData assigns a key value pair to an account
|
|
||||||
func (a *accountantServer) AssignValue(_ context.Context, in *accounts.DataKeyValue) (*accounts.DataKeyResponse, error) {
|
|
||||||
a.sync.RLock()
|
|
||||||
defer a.sync.RUnlock()
|
|
||||||
|
|
||||||
// Try and assign the data
|
|
||||||
log.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 {
|
|
||||||
log.Printf("Error: %s\n", err)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &accounts.DataKeyResponse{}, 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 value
|
|
||||||
data, err := a.accountant.GetValue(in.Account, in.Key)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Error: %s\n", err)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &accounts.DataResponse{Value: data}, nil
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// main
|
|
||||||
func main() {
|
|
||||||
// Get the port
|
|
||||||
var iport int
|
|
||||||
var port = os.Getenv("PORT")
|
|
||||||
if len(port) == 0 {
|
|
||||||
iport = 9091
|
|
||||||
} else {
|
|
||||||
var err error
|
|
||||||
iport, err = strconv.Atoi(port)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal("$PORT not valid int")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
persistence.SetPath(data)
|
|
||||||
|
|
||||||
// Initialise and load the accountant
|
|
||||||
accountant := internal.NewAccountant()
|
|
||||||
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", fmt.Sprintf(":%d", iport))
|
|
||||||
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
|
|
||||||
log.Println("Quit requested, exiting...")
|
|
||||||
grpcServer.Stop()
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Serve the RPC server
|
|
||||||
log.Printf("Serving accountant on %s\n", port)
|
|
||||||
if err := grpcServer.Serve(lis); err != nil {
|
|
||||||
log.Fatalf("failed to serve gRPC: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save out the accountant data
|
|
||||||
if err := persistence.Save("accounts", accountant); err != nil {
|
|
||||||
log.Fatalf("failed to save accounts: %s", err)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,11 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/mdiluz/rove/pkg/accounts"
|
|
||||||
"github.com/mdiluz/rove/pkg/game"
|
"github.com/mdiluz/rove/pkg/game"
|
||||||
"github.com/mdiluz/rove/pkg/rove"
|
"github.com/mdiluz/rove/pkg/rove"
|
||||||
"github.com/mdiluz/rove/pkg/version"
|
"github.com/mdiluz/rove/pkg/version"
|
||||||
"google.golang.org/grpc"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Server) Status(context.Context, *rove.StatusRequest) (*rove.StatusResponse, error) {
|
func (s *Server) Status(context.Context, *rove.StatusRequest) (*rove.StatusResponse, error) {
|
||||||
|
@ -33,7 +31,7 @@ func (s *Server) Register(ctx context.Context, req *rove.RegisterRequest) (*rove
|
||||||
return nil, fmt.Errorf("empty account name")
|
return nil, fmt.Errorf("empty account name")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := s.accountant.Register(ctx, &accounts.RegisterInfo{Name: req.Name}, grpc.WaitForReady(true)); err != nil {
|
if _, err := s.accountant.RegisterAccount(req.Name); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
||||||
} else if _, err := s.SpawnRoverForAccount(req.Name); err != nil {
|
} else if _, err := s.SpawnRoverForAccount(req.Name); err != nil {
|
||||||
|
@ -51,10 +49,10 @@ func (s *Server) Rover(ctx context.Context, req *rove.RoverRequest) (*rove.Rover
|
||||||
if len(req.Account) == 0 {
|
if len(req.Account) == 0 {
|
||||||
return nil, fmt.Errorf("empty account name")
|
return nil, fmt.Errorf("empty account name")
|
||||||
|
|
||||||
} else if resp, err := s.accountant.GetValue(ctx, &accounts.DataKey{Account: req.Account, Key: "rover"}); err != nil {
|
} else if resp, err := s.accountant.GetValue(req.Account, "rover"); err != nil {
|
||||||
return nil, fmt.Errorf("gRPC failed to contact accountant: %s", err)
|
return nil, err
|
||||||
|
|
||||||
} else if rover, err := s.world.GetRover(resp.Value); err != nil {
|
} else if rover, err := s.world.GetRover(resp); err != nil {
|
||||||
return nil, fmt.Errorf("error getting rover: %s", err)
|
return nil, fmt.Errorf("error getting rover: %s", err)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -79,14 +77,14 @@ func (s *Server) Radar(ctx context.Context, req *rove.RadarRequest) (*rove.Radar
|
||||||
|
|
||||||
response := &rove.RadarResponse{}
|
response := &rove.RadarResponse{}
|
||||||
|
|
||||||
resp, err := s.accountant.GetValue(ctx, &accounts.DataKey{Account: req.Account, Key: "rover"})
|
resp, err := s.accountant.GetValue(req.Account, "rover")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("gRPC failed to contact accountant: %s", err)
|
return nil, err
|
||||||
|
|
||||||
} else if rover, err := s.world.GetRover(resp.Value); err != nil {
|
} else if rover, err := s.world.GetRover(resp); err != nil {
|
||||||
return nil, fmt.Errorf("error getting rover attributes: %s", err)
|
return nil, fmt.Errorf("error getting rover attributes: %s", err)
|
||||||
|
|
||||||
} else if radar, err := s.world.RadarFromRover(resp.Value); err != nil {
|
} else if radar, err := s.world.RadarFromRover(resp); err != nil {
|
||||||
return nil, fmt.Errorf("error getting radar from rover: %s", err)
|
return nil, fmt.Errorf("error getting radar from rover: %s", err)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -101,8 +99,7 @@ func (s *Server) Commands(ctx context.Context, req *rove.CommandsRequest) (*rove
|
||||||
if len(req.Account) == 0 {
|
if len(req.Account) == 0 {
|
||||||
return nil, fmt.Errorf("empty account")
|
return nil, fmt.Errorf("empty account")
|
||||||
}
|
}
|
||||||
resp, err := s.accountant.GetValue(ctx, &accounts.DataKey{Account: req.Account, Key: "rover"})
|
resp, err := s.accountant.GetValue(req.Account, "rover")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -114,7 +111,7 @@ func (s *Server) Commands(ctx context.Context, req *rove.CommandsRequest) (*rove
|
||||||
Command: c.Command})
|
Command: c.Command})
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.world.Enqueue(resp.Value, cmds...); err != nil {
|
if err := s.world.Enqueue(resp, cmds...); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package internal
|
package internal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/mdiluz/rove/pkg/accounts"
|
"github.com/mdiluz/rove/pkg/accounts"
|
||||||
|
@ -30,9 +28,8 @@ type Server struct {
|
||||||
// Internal state
|
// Internal state
|
||||||
world *game.World
|
world *game.World
|
||||||
|
|
||||||
// Accountant server
|
// Accountant
|
||||||
accountant accounts.AccountantClient
|
accountant *accounts.Accountant
|
||||||
clientConn *grpc.ClientConn
|
|
||||||
|
|
||||||
// gRPC server
|
// gRPC server
|
||||||
netListener net.Listener
|
netListener net.Listener
|
||||||
|
@ -84,6 +81,7 @@ func NewServer(opts ...ServerOption) *Server {
|
||||||
persistence: EphemeralData,
|
persistence: EphemeralData,
|
||||||
schedule: cron.New(),
|
schedule: cron.New(),
|
||||||
world: game.NewWorld(32),
|
world: game.NewWorld(32),
|
||||||
|
accountant: accounts.NewAccountant(),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply all options
|
// Apply all options
|
||||||
|
@ -100,18 +98,6 @@ func (s *Server) Initialise(fillWorld bool) (err error) {
|
||||||
// Add to our sync
|
// Add to our sync
|
||||||
s.sync.Add(1)
|
s.sync.Add(1)
|
||||||
|
|
||||||
// Connect to the accountant
|
|
||||||
accountantAddress := os.Getenv("ROVE_ACCOUNTANT_GRPC")
|
|
||||||
if len(accountantAddress) == 0 {
|
|
||||||
accountantAddress = "localhost:9091"
|
|
||||||
}
|
|
||||||
log.Printf("Dialing accountant on %s\n", accountantAddress)
|
|
||||||
s.clientConn, err = grpc.Dial(accountantAddress, grpc.WithInsecure())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
s.accountant = accounts.NewAccountantClient(s.clientConn)
|
|
||||||
|
|
||||||
// Load the world file
|
// Load the world file
|
||||||
if err := s.LoadWorld(); err != nil {
|
if err := s.LoadWorld(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -173,11 +159,6 @@ func (s *Server) Stop() error {
|
||||||
// Stop the gRPC
|
// Stop the gRPC
|
||||||
s.grpcServ.Stop()
|
s.grpcServ.Stop()
|
||||||
|
|
||||||
// Close the accountant connection
|
|
||||||
if err := s.clientConn.Close(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +171,7 @@ func (s *Server) Close() error {
|
||||||
return s.SaveWorld()
|
return s.SaveWorld()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close waits until the server is finished and closes up shop
|
// StopAndClose waits until the server is finished and closes up shop
|
||||||
func (s *Server) StopAndClose() error {
|
func (s *Server) StopAndClose() error {
|
||||||
// Stop the server
|
// Stop the server
|
||||||
if err := s.Stop(); err != nil {
|
if err := s.Stop(); err != nil {
|
||||||
|
@ -225,19 +206,12 @@ func (s *Server) LoadWorld() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// used as the type for the return struct
|
|
||||||
type BadRequestError struct {
|
|
||||||
Error string `json:"error"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// SpawnRoverForAccount spawns the rover rover for an account
|
// SpawnRoverForAccount spawns the rover rover for an account
|
||||||
func (s *Server) SpawnRoverForAccount(account string) (string, error) {
|
func (s *Server) SpawnRoverForAccount(account string) (string, error) {
|
||||||
if inst, err := s.world.SpawnRover(); err != nil {
|
if inst, err := s.world.SpawnRover(); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
keyval := accounts.DataKeyValue{Account: account, Key: "rover", Value: inst}
|
err := s.accountant.AssignData(account, "rover", inst)
|
||||||
_, err := s.accountant.AssignValue(context.Background(), &keyval)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to assign rover to account, %s", err)
|
log.Printf("Failed to assign rover to account, %s", err)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package internal
|
package internal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -31,7 +30,6 @@ func TestNewServer_OptionPersistentData(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestServer_Run(t *testing.T) {
|
func TestServer_Run(t *testing.T) {
|
||||||
os.Setenv("ROVE_ACCOUNTANT_GRPC", "n/a")
|
|
||||||
server := NewServer()
|
server := NewServer()
|
||||||
if server == nil {
|
if server == nil {
|
||||||
t.Error("Failed to create server")
|
t.Error("Failed to create server")
|
||||||
|
@ -47,7 +45,6 @@ func TestServer_Run(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestServer_RunPersistentData(t *testing.T) {
|
func TestServer_RunPersistentData(t *testing.T) {
|
||||||
os.Setenv("ROVE_ACCOUNTANT_GRPC", "n/a")
|
|
||||||
server := NewServer(OptionPersistentData())
|
server := NewServer(OptionPersistentData())
|
||||||
if server == nil {
|
if server == nil {
|
||||||
t.Error("Failed to create server")
|
t.Error("Failed to create server")
|
||||||
|
|
|
@ -4,18 +4,6 @@ volumes:
|
||||||
persistent-data:
|
persistent-data:
|
||||||
|
|
||||||
services:
|
services:
|
||||||
rove-accountant:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
image: rove:latest
|
|
||||||
environment:
|
|
||||||
- PORT=9091
|
|
||||||
- DATA_PATH=/mnt/rove-server
|
|
||||||
volumes:
|
|
||||||
- persistent-data:/mnt/rove-server:rw
|
|
||||||
command: [ ./rove-accountant ]
|
|
||||||
|
|
||||||
rove-docs:
|
rove-docs:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
|
@ -27,7 +15,6 @@ services:
|
||||||
- PORT=80
|
- PORT=80
|
||||||
|
|
||||||
rove-server:
|
rove-server:
|
||||||
depends_on: [ rove-accountant ]
|
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
@ -37,11 +24,10 @@ services:
|
||||||
environment:
|
environment:
|
||||||
- PORT=9090
|
- PORT=9090
|
||||||
- DATA_PATH=/mnt/rove-server
|
- DATA_PATH=/mnt/rove-server
|
||||||
- ROVE_ACCOUNTANT_GRPC=rove-accountant:9091
|
|
||||||
- WORDS_FILE=data/words_alpha.txt
|
- WORDS_FILE=data/words_alpha.txt
|
||||||
volumes:
|
volumes:
|
||||||
- persistent-data:/mnt/rove-server:rw
|
- persistent-data:/mnt/rove-server:rw
|
||||||
command: [ "./script/wait-for-it.sh", "rove-accountant:9091", "--", "./rove-server"]
|
command: [ "./rove-server"]
|
||||||
|
|
||||||
rove:
|
rove:
|
||||||
depends_on: [ rove-server, rove-docs ]
|
depends_on: [ rove-server, rove-docs ]
|
||||||
|
@ -63,7 +49,6 @@ services:
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
image: rove:latest
|
image: rove:latest
|
||||||
environment:
|
environment:
|
||||||
- ROVE_ACCOUNTANT_GRPC=rove-accountant:9091
|
|
||||||
- ROVE_HTTP=rove
|
- ROVE_HTTP=rove
|
||||||
- ROVE_GRPC=rove-server
|
- ROVE_GRPC=rove-server
|
||||||
command: [ "./script/wait-for-it.sh", "rove:8080", "--", "go", "test", "-v", "./...", "--tags=integration", "-cover", "-coverprofile=/mnt/coverage-data/c.out", "-count", "1" ]
|
command: [ "./script/wait-for-it.sh", "rove:8080", "--", "go", "test", "-v", "./...", "--tags=integration", "-cover", "-coverprofile=/mnt/coverage-data/c.out", "-count", "1" ]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package internal
|
package accounts
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -16,10 +16,6 @@ type Account struct {
|
||||||
Data map[string]string `json:"data"`
|
Data map[string]string `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Represents the accountant data to store
|
|
||||||
type accountantData struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Accountant manages a set of accounts
|
// Accountant manages a set of accounts
|
||||||
type Accountant struct {
|
type Accountant struct {
|
||||||
Accounts map[string]Account `json:"accounts"`
|
Accounts map[string]Account `json:"accounts"`
|
|
@ -1,663 +0,0 @@
|
||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// protoc-gen-go v1.23.0
|
|
||||||
// protoc v3.6.1
|
|
||||||
// source: accounts/accounts.proto
|
|
||||||
|
|
||||||
package accounts
|
|
||||||
|
|
||||||
import (
|
|
||||||
context "context"
|
|
||||||
proto "github.com/golang/protobuf/proto"
|
|
||||||
grpc "google.golang.org/grpc"
|
|
||||||
codes "google.golang.org/grpc/codes"
|
|
||||||
status "google.golang.org/grpc/status"
|
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
|
||||||
sync "sync"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
// Verify that this generated code is sufficiently up-to-date.
|
|
||||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
|
||||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
|
||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
|
||||||
)
|
|
||||||
|
|
||||||
// This is a compile-time assertion that a sufficiently up-to-date version
|
|
||||||
// of the legacy proto package is being used.
|
|
||||||
const _ = proto.ProtoPackageIsVersion4
|
|
||||||
|
|
||||||
// RegisterInfo contains the information needed to register an account
|
|
||||||
type RegisterInfo struct {
|
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
|
|
||||||
// The name for the account, must be unique
|
|
||||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *RegisterInfo) Reset() {
|
|
||||||
*x = RegisterInfo{}
|
|
||||||
if protoimpl.UnsafeEnabled {
|
|
||||||
mi := &file_accounts_accounts_proto_msgTypes[0]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *RegisterInfo) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*RegisterInfo) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *RegisterInfo) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_accounts_accounts_proto_msgTypes[0]
|
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use RegisterInfo.ProtoReflect.Descriptor instead.
|
|
||||||
func (*RegisterInfo) Descriptor() ([]byte, []int) {
|
|
||||||
return file_accounts_accounts_proto_rawDescGZIP(), []int{0}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *RegisterInfo) GetName() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Name
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterResponse is the response information from registering an account
|
|
||||||
type RegisterResponse struct {
|
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *RegisterResponse) Reset() {
|
|
||||||
*x = RegisterResponse{}
|
|
||||||
if protoimpl.UnsafeEnabled {
|
|
||||||
mi := &file_accounts_accounts_proto_msgTypes[1]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *RegisterResponse) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*RegisterResponse) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *RegisterResponse) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_accounts_accounts_proto_msgTypes[1]
|
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use RegisterResponse.ProtoReflect.Descriptor instead.
|
|
||||||
func (*RegisterResponse) Descriptor() ([]byte, []int) {
|
|
||||||
return file_accounts_accounts_proto_rawDescGZIP(), []int{1}
|
|
||||||
}
|
|
||||||
|
|
||||||
// DataKeyValue represents a simple key value pair to assign to an account
|
|
||||||
type DataKeyValue struct {
|
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
|
|
||||||
// The account to assign the new key value pair to
|
|
||||||
Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"`
|
|
||||||
// The key value pair to assign
|
|
||||||
Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
|
|
||||||
Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DataKeyValue) Reset() {
|
|
||||||
*x = DataKeyValue{}
|
|
||||||
if protoimpl.UnsafeEnabled {
|
|
||||||
mi := &file_accounts_accounts_proto_msgTypes[2]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DataKeyValue) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*DataKeyValue) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *DataKeyValue) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_accounts_accounts_proto_msgTypes[2]
|
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use DataKeyValue.ProtoReflect.Descriptor instead.
|
|
||||||
func (*DataKeyValue) Descriptor() ([]byte, []int) {
|
|
||||||
return file_accounts_accounts_proto_rawDescGZIP(), []int{2}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DataKeyValue) GetAccount() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Account
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DataKeyValue) GetKey() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Key
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DataKeyValue) GetValue() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Value
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// DataKeyResponse is a simple response
|
|
||||||
type DataKeyResponse struct {
|
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DataKeyResponse) Reset() {
|
|
||||||
*x = DataKeyResponse{}
|
|
||||||
if protoimpl.UnsafeEnabled {
|
|
||||||
mi := &file_accounts_accounts_proto_msgTypes[3]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DataKeyResponse) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*DataKeyResponse) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *DataKeyResponse) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_accounts_accounts_proto_msgTypes[3]
|
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use DataKeyResponse.ProtoReflect.Descriptor instead.
|
|
||||||
func (*DataKeyResponse) Descriptor() ([]byte, []int) {
|
|
||||||
return file_accounts_accounts_proto_rawDescGZIP(), []int{3}
|
|
||||||
}
|
|
||||||
|
|
||||||
// DataKey describes a simple key value with an account, for fetching
|
|
||||||
type DataKey struct {
|
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
|
|
||||||
// The account to fetch data for
|
|
||||||
Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"`
|
|
||||||
// The key to fetch
|
|
||||||
Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DataKey) Reset() {
|
|
||||||
*x = DataKey{}
|
|
||||||
if protoimpl.UnsafeEnabled {
|
|
||||||
mi := &file_accounts_accounts_proto_msgTypes[4]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DataKey) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*DataKey) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *DataKey) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_accounts_accounts_proto_msgTypes[4]
|
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use DataKey.ProtoReflect.Descriptor instead.
|
|
||||||
func (*DataKey) Descriptor() ([]byte, []int) {
|
|
||||||
return file_accounts_accounts_proto_rawDescGZIP(), []int{4}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DataKey) GetAccount() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Account
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DataKey) GetKey() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Key
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// DataResponse describes a data fetch response
|
|
||||||
type DataResponse struct {
|
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
|
|
||||||
// The value of the key
|
|
||||||
Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DataResponse) Reset() {
|
|
||||||
*x = DataResponse{}
|
|
||||||
if protoimpl.UnsafeEnabled {
|
|
||||||
mi := &file_accounts_accounts_proto_msgTypes[5]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DataResponse) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*DataResponse) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *DataResponse) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_accounts_accounts_proto_msgTypes[5]
|
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use DataResponse.ProtoReflect.Descriptor instead.
|
|
||||||
func (*DataResponse) Descriptor() ([]byte, []int) {
|
|
||||||
return file_accounts_accounts_proto_rawDescGZIP(), []int{5}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DataResponse) GetValue() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Value
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
var File_accounts_accounts_proto protoreflect.FileDescriptor
|
|
||||||
|
|
||||||
var file_accounts_accounts_proto_rawDesc = []byte{
|
|
||||||
0x0a, 0x17, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75,
|
|
||||||
0x6e, 0x74, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x61, 0x63, 0x63, 0x6f, 0x75,
|
|
||||||
0x6e, 0x74, 0x73, 0x22, 0x22, 0x0a, 0x0c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49,
|
|
||||||
0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
|
||||||
0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x12, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73,
|
|
||||||
0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x50, 0x0a, 0x0c, 0x44,
|
|
||||||
0x61, 0x74, 0x61, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61,
|
|
||||||
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63,
|
|
||||||
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01,
|
|
||||||
0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
|
|
||||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x11, 0x0a,
|
|
||||||
0x0f, 0x44, 0x61, 0x74, 0x61, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
|
||||||
0x22, 0x35, 0x0a, 0x07, 0x44, 0x61, 0x74, 0x61, 0x4b, 0x65, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x61,
|
|
||||||
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63,
|
|
||||||
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01,
|
|
||||||
0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x24, 0x0a, 0x0c, 0x44, 0x61, 0x74, 0x61, 0x52,
|
|
||||||
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
|
|
||||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x32, 0xcb, 0x01,
|
|
||||||
0x0a, 0x0a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x61, 0x6e, 0x74, 0x12, 0x40, 0x0a, 0x08,
|
|
||||||
0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75,
|
|
||||||
0x6e, 0x74, 0x73, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f,
|
|
||||||
0x1a, 0x1a, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x52, 0x65, 0x67, 0x69,
|
|
||||||
0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x42,
|
|
||||||
0x0a, 0x0b, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x16, 0x2e,
|
|
||||||
0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4b, 0x65, 0x79,
|
|
||||||
0x56, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x19, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73,
|
|
||||||
0x2e, 0x44, 0x61, 0x74, 0x61, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
|
||||||
0x22, 0x00, 0x12, 0x37, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x11,
|
|
||||||
0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4b, 0x65,
|
|
||||||
0x79, 0x1a, 0x16, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x44, 0x61, 0x74,
|
|
||||||
0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x25, 0x5a, 0x23, 0x67,
|
|
||||||
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a,
|
|
||||||
0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e,
|
|
||||||
0x74, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
file_accounts_accounts_proto_rawDescOnce sync.Once
|
|
||||||
file_accounts_accounts_proto_rawDescData = file_accounts_accounts_proto_rawDesc
|
|
||||||
)
|
|
||||||
|
|
||||||
func file_accounts_accounts_proto_rawDescGZIP() []byte {
|
|
||||||
file_accounts_accounts_proto_rawDescOnce.Do(func() {
|
|
||||||
file_accounts_accounts_proto_rawDescData = protoimpl.X.CompressGZIP(file_accounts_accounts_proto_rawDescData)
|
|
||||||
})
|
|
||||||
return file_accounts_accounts_proto_rawDescData
|
|
||||||
}
|
|
||||||
|
|
||||||
var file_accounts_accounts_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
|
||||||
var file_accounts_accounts_proto_goTypes = []interface{}{
|
|
||||||
(*RegisterInfo)(nil), // 0: accounts.RegisterInfo
|
|
||||||
(*RegisterResponse)(nil), // 1: accounts.RegisterResponse
|
|
||||||
(*DataKeyValue)(nil), // 2: accounts.DataKeyValue
|
|
||||||
(*DataKeyResponse)(nil), // 3: accounts.DataKeyResponse
|
|
||||||
(*DataKey)(nil), // 4: accounts.DataKey
|
|
||||||
(*DataResponse)(nil), // 5: accounts.DataResponse
|
|
||||||
}
|
|
||||||
var file_accounts_accounts_proto_depIdxs = []int32{
|
|
||||||
0, // 0: accounts.Accountant.Register:input_type -> accounts.RegisterInfo
|
|
||||||
2, // 1: accounts.Accountant.AssignValue:input_type -> accounts.DataKeyValue
|
|
||||||
4, // 2: accounts.Accountant.GetValue:input_type -> accounts.DataKey
|
|
||||||
1, // 3: accounts.Accountant.Register:output_type -> accounts.RegisterResponse
|
|
||||||
3, // 4: accounts.Accountant.AssignValue:output_type -> accounts.DataKeyResponse
|
|
||||||
5, // 5: accounts.Accountant.GetValue:output_type -> accounts.DataResponse
|
|
||||||
3, // [3:6] is the sub-list for method output_type
|
|
||||||
0, // [0:3] is the sub-list for method input_type
|
|
||||||
0, // [0:0] is the sub-list for extension type_name
|
|
||||||
0, // [0:0] is the sub-list for extension extendee
|
|
||||||
0, // [0:0] is the sub-list for field type_name
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() { file_accounts_accounts_proto_init() }
|
|
||||||
func file_accounts_accounts_proto_init() {
|
|
||||||
if File_accounts_accounts_proto != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !protoimpl.UnsafeEnabled {
|
|
||||||
file_accounts_accounts_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
|
||||||
switch v := v.(*RegisterInfo); i {
|
|
||||||
case 0:
|
|
||||||
return &v.state
|
|
||||||
case 1:
|
|
||||||
return &v.sizeCache
|
|
||||||
case 2:
|
|
||||||
return &v.unknownFields
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
file_accounts_accounts_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
|
||||||
switch v := v.(*RegisterResponse); i {
|
|
||||||
case 0:
|
|
||||||
return &v.state
|
|
||||||
case 1:
|
|
||||||
return &v.sizeCache
|
|
||||||
case 2:
|
|
||||||
return &v.unknownFields
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
file_accounts_accounts_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
|
||||||
switch v := v.(*DataKeyValue); i {
|
|
||||||
case 0:
|
|
||||||
return &v.state
|
|
||||||
case 1:
|
|
||||||
return &v.sizeCache
|
|
||||||
case 2:
|
|
||||||
return &v.unknownFields
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
file_accounts_accounts_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
|
||||||
switch v := v.(*DataKeyResponse); i {
|
|
||||||
case 0:
|
|
||||||
return &v.state
|
|
||||||
case 1:
|
|
||||||
return &v.sizeCache
|
|
||||||
case 2:
|
|
||||||
return &v.unknownFields
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
file_accounts_accounts_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
|
||||||
switch v := v.(*DataKey); i {
|
|
||||||
case 0:
|
|
||||||
return &v.state
|
|
||||||
case 1:
|
|
||||||
return &v.sizeCache
|
|
||||||
case 2:
|
|
||||||
return &v.unknownFields
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
file_accounts_accounts_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
|
||||||
switch v := v.(*DataResponse); i {
|
|
||||||
case 0:
|
|
||||||
return &v.state
|
|
||||||
case 1:
|
|
||||||
return &v.sizeCache
|
|
||||||
case 2:
|
|
||||||
return &v.unknownFields
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
type x struct{}
|
|
||||||
out := protoimpl.TypeBuilder{
|
|
||||||
File: protoimpl.DescBuilder{
|
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
|
||||||
RawDescriptor: file_accounts_accounts_proto_rawDesc,
|
|
||||||
NumEnums: 0,
|
|
||||||
NumMessages: 6,
|
|
||||||
NumExtensions: 0,
|
|
||||||
NumServices: 1,
|
|
||||||
},
|
|
||||||
GoTypes: file_accounts_accounts_proto_goTypes,
|
|
||||||
DependencyIndexes: file_accounts_accounts_proto_depIdxs,
|
|
||||||
MessageInfos: file_accounts_accounts_proto_msgTypes,
|
|
||||||
}.Build()
|
|
||||||
File_accounts_accounts_proto = out.File
|
|
||||||
file_accounts_accounts_proto_rawDesc = nil
|
|
||||||
file_accounts_accounts_proto_goTypes = nil
|
|
||||||
file_accounts_accounts_proto_depIdxs = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 should create a new account in the database
|
|
||||||
// It will return an error if the account already exists
|
|
||||||
Register(ctx context.Context, in *RegisterInfo, opts ...grpc.CallOption) (*RegisterResponse, error)
|
|
||||||
// AssignValue assigns a key-value pair to an account, or overwrites an existing key
|
|
||||||
AssignValue(ctx context.Context, in *DataKeyValue, opts ...grpc.CallOption) (*DataKeyResponse, error)
|
|
||||||
// GetValue will get the value for a key for an account
|
|
||||||
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) (*DataKeyResponse, error) {
|
|
||||||
out := new(DataKeyResponse)
|
|
||||||
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 should create a new account in the database
|
|
||||||
// It will return an error if the account already exists
|
|
||||||
Register(context.Context, *RegisterInfo) (*RegisterResponse, error)
|
|
||||||
// AssignValue assigns a key-value pair to an account, or overwrites an existing key
|
|
||||||
AssignValue(context.Context, *DataKeyValue) (*DataKeyResponse, error)
|
|
||||||
// GetValue will get the value for a key for an account
|
|
||||||
GetValue(context.Context, *DataKey) (*DataResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnimplementedAccountantServer can be embedded to have forward compatible implementations.
|
|
||||||
type UnimplementedAccountantServer struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*UnimplementedAccountantServer) Register(context.Context, *RegisterInfo) (*RegisterResponse, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method Register not implemented")
|
|
||||||
}
|
|
||||||
func (*UnimplementedAccountantServer) AssignValue(context.Context, *DataKeyValue) (*DataKeyResponse, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method AssignValue not implemented")
|
|
||||||
}
|
|
||||||
func (*UnimplementedAccountantServer) GetValue(context.Context, *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/accounts.proto",
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
package internal
|
package accounts
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
|
@ -1,54 +0,0 @@
|
||||||
syntax = "proto3";
|
|
||||||
|
|
||||||
option go_package = "github.com/mdiluz/rove/pkg/accounts";
|
|
||||||
|
|
||||||
package accounts;
|
|
||||||
|
|
||||||
service Accountant {
|
|
||||||
// Register should create a new account in the database
|
|
||||||
// It will return an error if the account already exists
|
|
||||||
rpc Register(RegisterInfo) returns (RegisterResponse) {}
|
|
||||||
|
|
||||||
// AssignValue assigns a key-value pair to an account, or overwrites an existing key
|
|
||||||
rpc AssignValue(DataKeyValue) returns (DataKeyResponse) {}
|
|
||||||
|
|
||||||
// GetValue will get the value for a key for an account
|
|
||||||
rpc GetValue(DataKey) returns (DataResponse) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterInfo contains the information needed to register an account
|
|
||||||
message RegisterInfo {
|
|
||||||
// The name for the account, must be unique
|
|
||||||
string name = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterResponse is the response information from registering an account
|
|
||||||
message RegisterResponse {}
|
|
||||||
|
|
||||||
// DataKeyValue represents a simple key value pair to assign to an account
|
|
||||||
message DataKeyValue {
|
|
||||||
// The account to assign the new key value pair to
|
|
||||||
string account = 1;
|
|
||||||
|
|
||||||
// The key value pair to assign
|
|
||||||
string key = 2;
|
|
||||||
string value = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
// DataKeyResponse is a simple response
|
|
||||||
message DataKeyResponse {}
|
|
||||||
|
|
||||||
// DataKey describes a simple key value with an account, for fetching
|
|
||||||
message DataKey {
|
|
||||||
// The account to fetch data for
|
|
||||||
string account = 1;
|
|
||||||
|
|
||||||
// The key to fetch
|
|
||||||
string key = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// DataResponse describes a data fetch response
|
|
||||||
message DataResponse {
|
|
||||||
// The value of the key
|
|
||||||
string value = 3;
|
|
||||||
}
|
|
|
@ -18,6 +18,7 @@ apps:
|
||||||
- network
|
- network
|
||||||
environment:
|
environment:
|
||||||
ROVE_USER_DATA: $SNAP_USER_DATA
|
ROVE_USER_DATA: $SNAP_USER_DATA
|
||||||
|
|
||||||
rove-server:
|
rove-server:
|
||||||
command: bin/rove-server
|
command: bin/rove-server
|
||||||
plugs:
|
plugs:
|
||||||
|
@ -26,13 +27,7 @@ apps:
|
||||||
environment:
|
environment:
|
||||||
WORDS_FILE : "$SNAP/data/words_alpha.txt"
|
WORDS_FILE : "$SNAP/data/words_alpha.txt"
|
||||||
DATA_PATH : $SNAP_USER_DATA
|
DATA_PATH : $SNAP_USER_DATA
|
||||||
rove-accountant:
|
|
||||||
command: bin/rove-accountant
|
|
||||||
plugs:
|
|
||||||
- network
|
|
||||||
- network-bind
|
|
||||||
environment:
|
|
||||||
DATA_PATH : $SNAP_USER_DATA
|
|
||||||
rove-rest-server:
|
rove-rest-server:
|
||||||
command: bin/rove-reverse-proxy
|
command: bin/rove-reverse-proxy
|
||||||
plugs:
|
plugs:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue