server

package
v0.0.0-...-c3ee977 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MysqlHost string
	MysqlUser string
	MysqlPass string
}

Config holds server configuration

func NewConfig

func NewConfig() *Config

NewConfig loads config from environment variables

type TodoEntry

type TodoEntry struct {
	gorm.Model
	Text  string
	Done  bool
	Owner string
}

TodoEntry is an object used for ORM mapping into the DB

func FromGrpc

func FromGrpc(grpcTodo *todomgrpb.Todo) *TodoEntry

FromGrpc returns DB object from GRPC object

func (*TodoEntry) ToGrpc

func (e *TodoEntry) ToGrpc() *todomgrpb.Todo

ToGrpc returns GRPC object from DB object

type TodoManagerServer

type TodoManagerServer struct {
	// contains filtered or unexported fields
}

TodoManagerServer implements gRPC server for todo manager

func NewTodoManagerServer

func NewTodoManagerServer(config *Config) *TodoManagerServer

NewTodoManagerServer creates a new TodoManagerServer

func (*TodoManagerServer) CreateTodo

func (t *TodoManagerServer) CreateTodo(ctx context.Context, todo *todomgrpb.Todo) (*todomgrpb.Todo, error)

CreateTodo stores new todo in database

func (*TodoManagerServer) DeleteTodo

DeleteTodo deletes a todo with a specified ID and owner, if it exists

func (*TodoManagerServer) GetTodo

func (t *TodoManagerServer) GetTodo(ctx context.Context, grpcTodo *todomgrpb.TodoIdReq) (*todomgrpb.Todo, error)

GetTodo returns todo with specified ID and owner, if it exists

func (*TodoManagerServer) ListTodos

ListTodos lists all todos owned by the user sent in request

func (*TodoManagerServer) Stop

func (t *TodoManagerServer) Stop()

Stop stops the server and frees resources

func (*TodoManagerServer) UpdateTodo

func (t *TodoManagerServer) UpdateTodo(ctx context.Context, grpcTodo *todomgrpb.Todo) (*todomgrpb.Todo, error)

UpdateTodo updates a todo with a specified ID and owner, if it exists

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL