Documentation ¶
Overview ¶
Package databroker contains a data broker implementation.
Index ¶
- Variables
- type ConfigSource
- type Server
- func (srv *Server) Delete(ctx context.Context, req *databroker.DeleteRequest) (*empty.Empty, error)
- func (srv *Server) Get(ctx context.Context, req *databroker.GetRequest) (*databroker.GetResponse, error)
- func (srv *Server) GetAll(ctx context.Context, req *databroker.GetAllRequest) (*databroker.GetAllResponse, error)
- func (srv *Server) GetTypes(ctx context.Context, _ *emptypb.Empty) (*databroker.GetTypesResponse, error)
- func (srv *Server) Set(ctx context.Context, req *databroker.SetRequest) (*databroker.SetResponse, error)
- func (srv *Server) Sync(req *databroker.SyncRequest, stream databroker.DataBrokerService_SyncServer) error
- func (srv *Server) SyncTypes(req *emptypb.Empty, stream databroker.DataBrokerService_SyncTypesServer) error
- type ServerOption
- func WithBTreeDegree(degree int) ServerOption
- func WithDeletePermanentlyAfter(dur time.Duration) ServerOption
- func WithSecret(secret []byte) ServerOption
- func WithStorageConnectionString(connStr string) ServerOption
- func WithStorageTLSConfig(tlsConfig *tls.Config) ServerOption
- func WithStorageType(typ string) ServerOption
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultDeletePermanentlyAfter is the default amount of time to wait before deleting // a record permanently. DefaultDeletePermanentlyAfter = time.Hour // DefaultBTreeDegree is the default number of items to store in each node of the BTree. DefaultBTreeDegree = 8 // DefaultStorageType is the default storage type that Server use DefaultStorageType = "memory" )
Functions ¶
This section is empty.
Types ¶
type ConfigSource ¶
type ConfigSource struct { config.ChangeDispatcher // contains filtered or unexported fields }
ConfigSource provides a new Config source that decorates an underlying config with configuration derived from the data broker.
func NewConfigSource ¶
func NewConfigSource(underlying config.Source, listeners ...config.ChangeListener) *ConfigSource
NewConfigSource creates a new ConfigSource.
func (*ConfigSource) GetConfig ¶
func (src *ConfigSource) GetConfig() *config.Config
GetConfig gets the current config.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements the databroker service using an in memory database.
func (*Server) Delete ¶
func (srv *Server) Delete(ctx context.Context, req *databroker.DeleteRequest) (*empty.Empty, error)
Delete deletes a record from the in-memory list.
func (*Server) Get ¶
func (srv *Server) Get(ctx context.Context, req *databroker.GetRequest) (*databroker.GetResponse, error)
Get gets a record from the in-memory list.
func (*Server) GetAll ¶
func (srv *Server) GetAll(ctx context.Context, req *databroker.GetAllRequest) (*databroker.GetAllResponse, error)
GetAll gets all the records from the in-memory list.
func (*Server) GetTypes ¶
func (srv *Server) GetTypes(ctx context.Context, _ *emptypb.Empty) (*databroker.GetTypesResponse, error)
GetTypes returns all the known record types.
func (*Server) Set ¶
func (srv *Server) Set(ctx context.Context, req *databroker.SetRequest) (*databroker.SetResponse, error)
Set updates a record in the in-memory list, or adds a new one.
func (*Server) Sync ¶
func (srv *Server) Sync(req *databroker.SyncRequest, stream databroker.DataBrokerService_SyncServer) error
Sync streams updates for the given record type.
func (*Server) SyncTypes ¶
func (srv *Server) SyncTypes(req *emptypb.Empty, stream databroker.DataBrokerService_SyncTypesServer) error
SyncTypes synchronizes all the known record types.
type ServerOption ¶
type ServerOption func(*serverConfig)
A ServerOption customizes the server.
func WithBTreeDegree ¶
func WithBTreeDegree(degree int) ServerOption
WithBTreeDegree sets the number of items to store in each node of the BTree.
func WithDeletePermanentlyAfter ¶
func WithDeletePermanentlyAfter(dur time.Duration) ServerOption
WithDeletePermanentlyAfter sets the deletePermanentlyAfter duration. If a record is deleted via Delete, it will be permanently deleted after the given duration.
func WithSecret ¶
func WithSecret(secret []byte) ServerOption
WithSecret sets the secret in the config.
func WithStorageConnectionString ¶
func WithStorageConnectionString(connStr string) ServerOption
WithStorageConnectionString sets the DSN for storage.
func WithStorageTLSConfig ¶
func WithStorageTLSConfig(tlsConfig *tls.Config) ServerOption
WithStorageTLSConfig sets the tls config for connection to storage.
func WithStorageType ¶
func WithStorageType(typ string) ServerOption
WithStorageType sets the storage type.