server

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2020 License: Apache-2.0 Imports: 41 Imported by: 4

Documentation

Index

Constants

View Source
const ErrConsistencyFail = "consistency check fail at index %d"

ErrConsistencyFail happens when a consistency check fails. Check the log to retrieve details on which element is failing

View Source
const IDENTIFIER_FNAME = "immudb.identifier"

IDENTIFIER_FNAME ...

View Source
const SERVER_UUID_HEADER = "immudb-uuid"

SERVER_UUID_HEADER ...

Variables

View Source
var ErrUserDeactivated = errors.New("user is deactivated")
View Source
var Metrics = MetricsCollection{
	RPCsPerClientCounters: promauto.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: metricsNamespace,
			Name:      "number_of_rpcs_per_client",
			Help:      "Number of handled RPCs per client.",
		},
		[]string{"ip"},
	),
	LastMessageAtPerClientGauges: promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: metricsNamespace,
			Name:      "clients_last_message_at_unix_seconds",
			Help:      "Timestamp at which clients have sent their most recent message.",
		},
		[]string{"ip"},
	),
}

Functions

func NewUuidContext

func NewUuidContext(id xid.ID) uuidContext

NewUuidContext return a new UUId context servive

func StartMetrics

func StartMetrics(
	addr string,
	l logger.Logger,
	recordsCounter func() float64,
	uptimeCounter func() float64,
) *http.Server

StartMetrics listens and servers the HTTP metrics server in a new goroutine. The server is then returned and can be stopped using Close().

Types

type CorruptionChecker

type CorruptionChecker interface {
	Start(context.Context) (err error)
	Stop(context.Context)
	GetStatus(context.Context) bool
	Wait()
}

ImmuTc trust checker interface

func NewCorruptionChecker

func NewCorruptionChecker(s *store.Store, l logger.Logger, stopImmudb func() error) CorruptionChecker

NewCorruptionChecker returns new trust checker service

type ImmuServer

type ImmuServer struct {
	Store      *store.Store
	SysStore   *store.Store
	Logger     logger.Logger
	Options    Options
	GrpcServer *grpc.Server
	Cc         CorruptionChecker
	Pid        PIDFile
	// contains filtered or unexported fields
}

func DefaultServer

func DefaultServer() *ImmuServer

func (*ImmuServer) ByIndex

func (s *ImmuServer) ByIndex(ctx context.Context, index *schema.Index) (*schema.Item, error)

func (*ImmuServer) ByIndexSV

func (s *ImmuServer) ByIndexSV(ctx context.Context, index *schema.Index) (*schema.StructuredItem, error)

func (*ImmuServer) BySafeIndex

func (s *ImmuServer) BySafeIndex(ctx context.Context, sio *schema.SafeIndexOptions) (*schema.SafeItem, error)

func (*ImmuServer) ChangePassword

func (s *ImmuServer) ChangePassword(ctx context.Context, r *schema.ChangePasswordRequest) (*empty.Empty, error)

func (*ImmuServer) Consistency

func (s *ImmuServer) Consistency(ctx context.Context, index *schema.Index) (*schema.ConsistencyProof, error)

func (*ImmuServer) Count

func (s *ImmuServer) Count(ctx context.Context, prefix *schema.KeyPrefix) (*schema.ItemsCount, error)

func (*ImmuServer) CreateAdminUser

func (s *ImmuServer) CreateAdminUser(ctx context.Context) (string, string, error)

func (*ImmuServer) CreateUser

func (*ImmuServer) CurrentRoot

func (s *ImmuServer) CurrentRoot(ctx context.Context, e *empty.Empty) (*schema.Root, error)

func (*ImmuServer) DeactivateUser

func (s *ImmuServer) DeactivateUser(ctx context.Context, r *schema.UserRequest) (*empty.Empty, error)

func (*ImmuServer) Dump

func (*ImmuServer) Get

func (s *ImmuServer) Get(ctx context.Context, k *schema.Key) (*schema.Item, error)

func (*ImmuServer) GetBatch

func (s *ImmuServer) GetBatch(ctx context.Context, kl *schema.KeyList) (*schema.ItemList, error)

func (*ImmuServer) GetBatchSV

func (s *ImmuServer) GetBatchSV(ctx context.Context, kl *schema.KeyList) (*schema.StructuredItemList, error)

func (*ImmuServer) GetSV

func (*ImmuServer) GetUser

func (*ImmuServer) Health

func (*ImmuServer) History

func (s *ImmuServer) History(ctx context.Context, key *schema.Key) (*schema.ItemList, error)

func (*ImmuServer) HistorySV

func (s *ImmuServer) HistorySV(ctx context.Context, key *schema.Key) (*schema.StructuredItemList, error)

func (*ImmuServer) IScan

func (s *ImmuServer) IScan(ctx context.Context, opts *schema.IScanOptions) (*schema.Page, error)

func (*ImmuServer) IScanSV

func (s *ImmuServer) IScanSV(ctx context.Context, opts *schema.IScanOptions) (*schema.SPage, error)

func (*ImmuServer) Inclusion

func (s *ImmuServer) Inclusion(ctx context.Context, index *schema.Index) (*schema.InclusionProof, error)

func (*ImmuServer) ListUsers

func (s *ImmuServer) ListUsers(ctx context.Context, req *empty.Empty) (*schema.UserList, error)

func (*ImmuServer) Login

func (*ImmuServer) Logout added in v0.6.1

func (s *ImmuServer) Logout(ctx context.Context, r *empty.Empty) (*empty.Empty, error)

func (*ImmuServer) PrintTree added in v0.6.1

func (s *ImmuServer) PrintTree(context.Context, *empty.Empty) (*schema.Tree, error)

func (*ImmuServer) Reference

func (s *ImmuServer) Reference(ctx context.Context, refOpts *schema.ReferenceOptions) (index *schema.Index, err error)

func (*ImmuServer) SafeGet

func (s *ImmuServer) SafeGet(ctx context.Context, opts *schema.SafeGetOptions) (*schema.SafeItem, error)

func (*ImmuServer) SafeGetSV

func (*ImmuServer) SafeReference

func (s *ImmuServer) SafeReference(ctx context.Context, safeRefOpts *schema.SafeReferenceOptions) (proof *schema.Proof, err error)

func (*ImmuServer) SafeSet

func (s *ImmuServer) SafeSet(ctx context.Context, opts *schema.SafeSetOptions) (*schema.Proof, error)

func (*ImmuServer) SafeSetSV

func (s *ImmuServer) SafeSetSV(ctx context.Context, sopts *schema.SafeSetSVOptions) (*schema.Proof, error)

func (*ImmuServer) SafeZAdd

func (s *ImmuServer) SafeZAdd(ctx context.Context, opts *schema.SafeZAddOptions) (*schema.Proof, error)

func (*ImmuServer) Scan

func (s *ImmuServer) Scan(ctx context.Context, opts *schema.ScanOptions) (*schema.ItemList, error)

func (*ImmuServer) ScanSV

func (*ImmuServer) Set

func (s *ImmuServer) Set(ctx context.Context, kv *schema.KeyValue) (*schema.Index, error)

func (*ImmuServer) SetBatch

func (s *ImmuServer) SetBatch(ctx context.Context, kvl *schema.KVList) (*schema.Index, error)

func (*ImmuServer) SetBatchSV

func (s *ImmuServer) SetBatchSV(ctx context.Context, skvl *schema.SKVList) (*schema.Index, error)

func (*ImmuServer) SetPermission

func (s *ImmuServer) SetPermission(ctx context.Context, r *schema.Item) (*empty.Empty, error)

func (*ImmuServer) SetSV

func (*ImmuServer) Start

func (s *ImmuServer) Start() error

func (*ImmuServer) Stop

func (s *ImmuServer) Stop() error

func (*ImmuServer) UpdateAuthConfig

func (s *ImmuServer) UpdateAuthConfig(ctx context.Context, req *schema.AuthConfig) (*empty.Empty, error)

func (*ImmuServer) UpdateMTLSConfig

func (s *ImmuServer) UpdateMTLSConfig(ctx context.Context, req *schema.MTLSConfig) (*empty.Empty, error)

func (*ImmuServer) WithCC

func (s *ImmuServer) WithCC(cc CorruptionChecker) *ImmuServer

func (*ImmuServer) WithLogger

func (s *ImmuServer) WithLogger(logger logger.Logger) *ImmuServer

func (*ImmuServer) WithOptions

func (s *ImmuServer) WithOptions(options Options) *ImmuServer

func (*ImmuServer) WithStore

func (s *ImmuServer) WithStore(st *store.Store) *ImmuServer

func (*ImmuServer) ZAdd

func (s *ImmuServer) ZAdd(ctx context.Context, opts *schema.ZAddOptions) (*schema.Index, error)

func (*ImmuServer) ZScan

func (s *ImmuServer) ZScan(ctx context.Context, opts *schema.ZScanOptions) (*schema.ItemList, error)

func (*ImmuServer) ZScanSV

type MTLsOptions

type MTLsOptions struct {
	Pkey        string
	Certificate string
	ClientCAs   string
}

func DefaultMTLsOptions

func DefaultMTLsOptions() MTLsOptions

func (MTLsOptions) WithCertificate

func (o MTLsOptions) WithCertificate(Certificate string) MTLsOptions

func (MTLsOptions) WithClientCAs

func (o MTLsOptions) WithClientCAs(ClientCAs string) MTLsOptions

func (MTLsOptions) WithPkey

func (o MTLsOptions) WithPkey(Pkey string) MTLsOptions

type MetricsCollection

type MetricsCollection struct {
	RecordsCounter               prometheus.CounterFunc
	UptimeCounter                prometheus.CounterFunc
	RPCsPerClientCounters        *prometheus.CounterVec
	LastMessageAtPerClientGauges *prometheus.GaugeVec
}

func (*MetricsCollection) UpdateClientMetrics

func (mc *MetricsCollection) UpdateClientMetrics(ctx context.Context)

func (*MetricsCollection) WithRecordsCounter

func (mc *MetricsCollection) WithRecordsCounter(f func() float64)

func (*MetricsCollection) WithUptimeCounter

func (mc *MetricsCollection) WithUptimeCounter(f func() float64)

type Options

type Options struct {
	Dir             string
	Network         string
	Address         string
	Port            int
	MetricsPort     int
	DbName          string
	SysDbName       string
	Config          string
	Pidfile         string
	Logfile         string
	MTLs            bool
	MTLsOptions     MTLsOptions
	Auth            bool
	NoHistograms    bool
	Detached        bool
	CorruptionCheck bool
	MetricsServer   bool
}

Options server options list

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns default server options

func (Options) Bind

func (o Options) Bind() string

Bind returns bind address

func (Options) MetricsBind

func (o Options) MetricsBind() string

MetricsBind return metrics bind address

func (Options) String

func (o Options) String() string

String print options

func (Options) WithAddress

func (o Options) WithAddress(address string) Options

WithAddress sets address

func (Options) WithAuth

func (o Options) WithAuth(authEnabled bool) Options

WithAuth sets auth

func (Options) WithConfig

func (o Options) WithConfig(config string) Options

WithConfig sets config file name

func (Options) WithCorruptionCheck

func (o Options) WithCorruptionCheck(corruptionCheck bool) Options

WithCorruptionCheck enable corruption check

func (Options) WithDbName

func (o Options) WithDbName(dbName string) Options

WithDbName sets dbName

func (Options) WithDetached

func (o Options) WithDetached(detached bool) Options

WithDetached sets immudb to be run in background

func (Options) WithDir

func (o Options) WithDir(dir string) Options

WithDir sets dir

func (Options) WithLogfile

func (o Options) WithLogfile(logfile string) Options

WithLogfile sets logfile

func (Options) WithMTLs

func (o Options) WithMTLs(MTLs bool) Options

WithMTLs sets mtls

func (Options) WithMTLsOptions

func (o Options) WithMTLsOptions(MTLsOptions MTLsOptions) Options

WithMTLsOptions sets WithMTLsOptions

func (Options) WithMetricsServer

func (o Options) WithMetricsServer(metricsServer bool) Options

func (Options) WithNetwork

func (o Options) WithNetwork(network string) Options

WithNetwork sets network

func (Options) WithNoHistograms

func (o Options) WithNoHistograms(noHistograms bool) Options

WithNoHistograms disables collection of histograms metrics (e.g. query durations)

func (Options) WithPidfile

func (o Options) WithPidfile(pidfile string) Options

WithPidfile sets pid file

func (Options) WithPort

func (o Options) WithPort(port int) Options

WithPort sets port

func (Options) WithSysDbName

func (o Options) WithSysDbName(sysDbName string) Options

WithSysDbName sets SysDbName

type PIDFile

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

PIDFile contains path of pid file

func NewPid

func NewPid(path string) (PIDFile, error)

NewPid returns a new PIDFile or an error

func (PIDFile) Remove

func (file PIDFile) Remove() error

Remove remove the pid file

type Service

type Service struct {
	ImmuServer
}

func (Service) Run

func (s Service) Run()

Run - blocking run service

func (Service) Start

func (s Service) Start()

Start - non-blocking start service

func (Service) Stop

func (s Service) Stop()

Stop - non-blocking stop service

type UUIDContext

type UUIDContext interface {
	UuidStreamContextSetter(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error
	UuidContextSetter(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
}

UUIDContext manage UUID context

type WrappedServerStream

type WrappedServerStream struct {
	grpc.ServerStream
}

WrappedServerStream ...

func (*WrappedServerStream) RecvMsg

func (w *WrappedServerStream) RecvMsg(m interface{}) error

RecvMsg ...

func (*WrappedServerStream) SendMsg

func (w *WrappedServerStream) SendMsg(m interface{}) error

SendMsg ...

Jump to

Keyboard shortcuts

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