Documentation ¶
Overview ¶
Package server defines a gRPC server.
Index ¶
- type Option
- func WithBoltDB(path, col string) Option
- func WithHTTPPort(port string) Option
- func WithInsecureGRPCServer() Option
- func WithJSONLogger(out io.Writer) Option
- func WithJWTAuthToken(key string) Option
- func WithListener(addr string) Option
- func WithPostgresDB(host, port, dbName, table, user, password string, conns int, ...) Option
- func WithRistrettoCache(cap int) Option
- func WithSQLiteDB(path, table string, conns int, lifeConns time.Duration) Option
- func WithSecuredGRPCServer(crt, key, ca string) Option
- func WithTestDB() Option
- func WithTextLogger(out io.Writer) Option
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(s *server) error
Option represents an option for a new *server.
func WithBoltDB ¶
WithBoltDB receives a path and a colletion to create a BoltDB client and assign it to the new server. If something goes wrong while configuring the client it returns a non-nil error.
func WithHTTPPort ¶
WithHTTPPort returns an Option to a new Server that assigns to its httpPort field the received port.
func WithInsecureGRPCServer ¶
func WithInsecureGRPCServer() Option
WithInsecureGRPCServer returns an Option to a new Server that assigns to its srv field a insecure gRPC server.
func WithJSONLogger ¶
WithJSONLogger returns an Option to a new Server with a JSON based logger.
func WithJWTAuthToken ¶
WithJWTAuthToken returns an Option to a new Server that creates from the received key a JWT that is assigned to the Server.
func WithListener ¶
WithListener returns an Option to a new Server that assigns to its listener field a TCP listener with the received address.
func WithPostgresDB ¶
func WithPostgresDB(host, port, dbName, table, user, password string, conns int, lifeConns time.Duration) Option
WithPostgresDB receives a set of parameters to create a PostgreSQL client and assign it to the new server. If something goes wrong while configuring the client it returns a non-nil error.
func WithRistrettoCache ¶
WithRistrettoCache returns an Option to a new Server that assigns to its cache a Ristretto's based cache.
func WithSQLiteDB ¶
WithSQLiteDB receives a set of basic parameters to create a SQLite3 client and assigns it to the new Server. If something goes wrong while configuring the the client it returns a non-nil error.
func WithSecuredGRPCServer ¶
WithSecuredGRPCServer returns an Option to a new Server that assigns to its srv field a secured gRPC server with TLS.
func WithTestDB ¶
func WithTestDB() Option
WithTestDB returns an Option to a new server that assigns to its db field an in-memory database for testing.
func WithTextLogger ¶
WithTextLogger returns an Option to a new Server with a text based logger.
type Server ¶
type Server interface { AddCommand(context.Context, *proto.BotCommand) (*empty.Empty, error) GetCommand(context.Context, *proto.Command) (*proto.BotCommand, error) ListCommands(context.Context, *empty.Empty) (*proto.BotCommands, error) UpdateCommand(context.Context, *proto.BotCommand) (*empty.Empty, error) DeleteCommand(context.Context, *proto.Command) (*empty.Empty, error) Connect() error Serve() error CloseList() }
Server represents a gRPC BotioServer with a method to connect to its database.