databroker

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2021 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package databroker contains a data broker implementation.

Index

Constants

This section is empty.

Variables

View Source
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"
	// DefaultGetAllPageSize is the default page size for GetAll calls.
	DefaultGetAllPageSize = 50
)

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 New

func New(options ...ServerOption) *Server

New creates a new server.

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

Get gets a record from the in-memory list.

func (*Server) GetAll

GetAll gets all the records from the backend.

func (*Server) GetTypes

func (srv *Server) GetTypes(ctx context.Context, _ *emptypb.Empty) (*databroker.GetTypesResponse, error)

GetTypes returns all the known record types.

func (*Server) Query added in v0.11.0

Query queries for records.

func (*Server) Set

Set updates a record in the in-memory list, or adds a new one.

func (*Server) Sync

Sync streams updates for the given record type.

func (*Server) SyncTypes

SyncTypes synchronizes all the known record types.

func (*Server) UpdateConfig added in v0.11.0

func (srv *Server) UpdateConfig(options ...ServerOption)

UpdateConfig updates the server with the new options.

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 WithGetAllPageSize added in v0.11.0

func WithGetAllPageSize(pageSize int) ServerOption

WithGetAllPageSize sets the page size for GetAll calls.

func WithSharedKey added in v0.11.0

func WithSharedKey(sharedKey string) ServerOption

WithSharedKey sets the secret in the config.

func WithStorageCAFile added in v0.11.0

func WithStorageCAFile(filePath string) ServerOption

WithStorageCAFile sets the CA file in the config.

func WithStorageCertSkipVerify added in v0.11.0

func WithStorageCertSkipVerify(storageCertSkipVerify bool) ServerOption

WithStorageCertSkipVerify sets the storageCertSkipVerify in the config.

func WithStorageCertificate added in v0.11.0

func WithStorageCertificate(certificate *tls.Certificate) ServerOption

WithStorageCertificate sets the storageCertificate in the config.

func WithStorageConnectionString

func WithStorageConnectionString(connStr string) ServerOption

WithStorageConnectionString sets the DSN for storage.

func WithStorageType

func WithStorageType(typ string) ServerOption

WithStorageType sets the storage type.

Jump to

Keyboard shortcuts

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