grpcclient

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: Apache-2.0 Imports: 36 Imported by: 4

Documentation

Index

Constants

View Source
const MaxCallRecvMsgSize = 32 << 20
View Source
const STATE_FN = ".state-"

STATE_FN ...

Variables

View Source
var ErrCacheAlreadyLocked = fmt.Errorf("cache is already locked")
View Source
var ErrCacheNotLocked = fmt.Errorf("cache is not locked")
View Source
var ErrLocalStateCorrupted = fmt.Errorf("local state is corrupted")
View Source
var ErrNoServerUuid = fmt.Errorf(
	"!IMPORTANT WARNING: %s header is not published by the immudb server; "+
		"this client MUST NOT be used to connect to different immudb servers!",
	server.SERVER_UUID_HEADER)

ErrNoServerUuid ...

View Source
var ErrPrevStateNotFound = fmt.Errorf("could not find previous state")
View Source
var ErrStateNotFound = fmt.Errorf("could not find previous state")

Functions

func NewLcStateService added in v0.9.1

func NewLcStateService(cache *FileCache,
	logger logger.Logger,
	stateProvider state.StateProvider,
	uuidProvider state.UUIDProvider) (state.StateService, error)

NewLcStateService ...

Types

type ApiKeyAuth

type ApiKeyAuth struct {
	ApiKey string
}

func (ApiKeyAuth) GetRequestMetadata

func (t ApiKeyAuth) GetRequestMetadata(ctx context.Context, in ...string) (map[string]string, error)

func (ApiKeyAuth) RequireTransportSecurity

func (ApiKeyAuth) RequireTransportSecurity() bool

type FileCache added in v0.9.1

type FileCache struct {
	Dir string
	// contains filtered or unexported fields
}

func NewLcFileCache added in v0.9.1

func NewLcFileCache(dir string) *FileCache

NewFileCache returns a new file cache

func (*FileCache) Get added in v0.9.1

func (w *FileCache) Get(serverUUID string, db string) (*schema.ImmutableState, error)

func (*FileCache) GetAndClean added in v0.9.1

func (w *FileCache) GetAndClean(serverUUID, db string) (*schema.ImmutableState, error)

GetAndClean retrieve the state for db identifier and remove it from state file

func (*FileCache) Lock added in v0.9.2

func (w *FileCache) Lock(serverUUID string) (err error)

func (*FileCache) Set added in v0.9.1

func (w *FileCache) Set(serverUUID string, db string, state *schema.ImmutableState) error

func (*FileCache) Unlock added in v0.9.2

func (w *FileCache) Unlock() (err error)

type LcClient

type LcClient struct {
	Dir                  string
	Host                 string
	Port                 int
	ApiKey               string
	MetadataPairs        []string
	DialOptions          []grpc.DialOption
	Logger               logger.Logger
	ClientConn           *grpc.ClientConn
	ServiceClient        schema.LcServiceClient
	StateService         state.StateService
	TimestampService     immuclient.TimestampService
	StreamChunkSize      int
	StreamServiceFactory stream.ServiceFactory

	sync.RWMutex
	// contains filtered or unexported fields
}

func NewLcClient

func NewLcClient(setters ...LcClientOption) *LcClient

func (*LcClient) ApiKeySetterInterceptor

func (c *LcClient) ApiKeySetterInterceptor() func(context.Context, string, interface{}, interface{}, *grpc.ClientConn, grpc.UnaryInvoker, ...grpc.CallOption) error

func (*LcClient) ApiKeySetterInterceptorStream added in v0.9.2

func (c *LcClient) ApiKeySetterInterceptorStream() func(context.Context, *grpc.StreamDesc, *grpc.ClientConn, string, grpc.Streamer, ...grpc.CallOption) (grpc.ClientStream, error)

ApiKeySetterInterceptorStream ...

func (*LcClient) Connect

func (c *LcClient) Connect() (err error)

func (*LcClient) ConnectionCheckerInterceptor

func (c *LcClient) ConnectionCheckerInterceptor() func(context.Context, string, interface{}, interface{}, *grpc.ClientConn, grpc.UnaryInvoker, ...grpc.CallOption) error

func (*LcClient) Disconnect

func (c *LcClient) Disconnect() (err error)

func (*LcClient) ExecAll added in v0.9.1

ExecAll ...

func (*LcClient) Feats added in v0.9.2

func (c *LcClient) Feats(ctx context.Context) (*schema.Features, error)

func (*LcClient) Get

func (c *LcClient) Get(ctx context.Context, key []byte) (*immuschema.Entry, error)

Get ...

func (*LcClient) GetAll added in v0.9.1

GetAll ...

func (*LcClient) GetAt added in v0.9.1

func (c *LcClient) GetAt(ctx context.Context, key []byte, tx uint64) (*immuschema.Entry, error)

GetAt ...

func (*LcClient) GetFile added in v0.9.2

func (c *LcClient) GetFile(ctx context.Context, key []byte, filePath string) (*immuschema.Entry, error)

GetFile ...

func (*LcClient) Health added in v0.9.1

func (*LcClient) History

History ...

func (*LcClient) HistoryExt

func (c *LcClient) HistoryExt(ctx context.Context, options *immuschema.HistoryRequest) (*schema.ItemExtList, error)

HistoryExt ...

func (*LcClient) Scan

Scan ...

func (*LcClient) Set

func (c *LcClient) Set(ctx context.Context, key []byte, value []byte) (*immuschema.TxMetadata, error)

Set ...

func (*LcClient) SetAll added in v0.9.2

func (*LcClient) SetFile added in v0.9.2

func (c *LcClient) SetFile(ctx context.Context, key []byte, filePath string) (*immuschema.TxMetadata, error)

SetFile ...

func (*LcClient) SignatureVerifierInterceptor added in v0.9.1

func (c *LcClient) SignatureVerifierInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error

SignatureVerifierInterceptor verify that provided server signature match with the public key provided

func (*LcClient) StreamExecAll added in v0.9.2

func (c *LcClient) StreamExecAll(ctx context.Context, req *stream.ExecAllRequest) (*schema.TxMetadata, error)

StreamExecAll ...

func (*LcClient) StreamGet added in v0.9.2

func (c *LcClient) StreamGet(ctx context.Context, k *immuschema.KeyRequest) (*immuschema.Entry, error)

StreamGet ...

func (*LcClient) StreamHistory added in v0.9.2

func (c *LcClient) StreamHistory(ctx context.Context, req *immuschema.HistoryRequest) (*immuschema.Entries, error)

StreamHistory ...

func (*LcClient) StreamScan added in v0.9.2

func (c *LcClient) StreamScan(ctx context.Context, req *immuschema.ScanRequest) (*immuschema.Entries, error)

StreamScan ...

func (*LcClient) StreamSet added in v0.9.2

func (c *LcClient) StreamSet(ctx context.Context, kvs []*stream.KeyValue) (*immuschema.TxMetadata, error)

StreamSet ...

func (*LcClient) StreamVerifiedGet added in v0.9.2

func (c *LcClient) StreamVerifiedGet(ctx context.Context, req *immuschema.VerifiableGetRequest) (*immuschema.Entry, error)

StreamVerifiedGet ...

func (*LcClient) StreamVerifiedSet added in v0.9.2

func (c *LcClient) StreamVerifiedSet(ctx context.Context, kvs []*stream.KeyValue) (*immuschema.TxMetadata, error)

StreamVerifiedSet ...

func (*LcClient) StreamZScan added in v0.9.2

func (c *LcClient) StreamZScan(ctx context.Context, req *immuschema.ZScanRequest) (*immuschema.ZEntries, error)

StreamZScan ...

func (*LcClient) VerifiedGet added in v0.9.1

func (c *LcClient) VerifiedGet(ctx context.Context, key []byte) (*immuschema.Entry, error)

VerifiedGet ...

func (*LcClient) VerifiedGetAt added in v0.9.1

func (c *LcClient) VerifiedGetAt(ctx context.Context, key []byte, tx uint64) (*immuschema.Entry, error)

VerifiedGetAt ...

func (*LcClient) VerifiedGetExt added in v0.9.1

func (c *LcClient) VerifiedGetExt(ctx context.Context, key []byte) (itemExt *schema.VerifiableItemExt, err error)

VerifiedGetExt ...

func (*LcClient) VerifiedGetExtAt added in v0.9.1

func (c *LcClient) VerifiedGetExtAt(ctx context.Context, key []byte, tx uint64) (itemExt *schema.VerifiableItemExt, err error)

VerifiedGetExtAt ...

func (*LcClient) VerifiedGetExtSince added in v0.9.1

func (c *LcClient) VerifiedGetExtSince(ctx context.Context, key []byte, tx uint64) (itemExt *schema.VerifiableItemExt, err error)

VerifiedGetExtSince ...

func (*LcClient) VerifiedGetSince added in v0.9.1

func (c *LcClient) VerifiedGetSince(ctx context.Context, key []byte, tx uint64) (*immuschema.Entry, error)

VerifiedGetSince ...

func (*LcClient) VerifiedSet added in v0.9.1

func (c *LcClient) VerifiedSet(ctx context.Context, key []byte, value []byte) (*immuschema.TxMetadata, error)

VerifiedSet ...

func (*LcClient) ZAddAt added in v0.9.1

ZAddAt ...

func (*LcClient) ZScan

ZScan ...

func (*LcClient) ZScanExt

func (c *LcClient) ZScanExt(ctx context.Context, options *immuschema.ZScanRequest) (*schema.ZItemExtList, error)

ZScanExt ...

type LcClientIf

type LcClientIf interface {
	Set(ctx context.Context, key []byte, value []byte) (*immuschema.TxMetadata, error)
	VerifiedSet(ctx context.Context, key []byte, value []byte) (*immuschema.TxMetadata, error)

	Get(ctx context.Context, key []byte) (*immuschema.Entry, error)
	GetAt(ctx context.Context, key []byte, tx uint64) (*immuschema.Entry, error)
	VerifiedGet(ctx context.Context, key []byte) (*immuschema.Entry, error)
	VerifiedGetSince(ctx context.Context, key []byte, tx uint64) (*immuschema.Entry, error)
	VerifiedGetAt(ctx context.Context, key []byte, tx uint64) (*immuschema.Entry, error)

	GetAll(ctx context.Context, in *immuschema.KeyListRequest) (*immuschema.Entries, error)
	SetAll(ctx context.Context, kvList *immuschema.SetRequest) (*immuschema.TxMetadata, error)

	ExecAll(ctx context.Context, in *immuschema.ExecAllRequest) (*immuschema.TxMetadata, error)

	Scan(ctx context.Context, req *immuschema.ScanRequest) (*immuschema.Entries, error)
	ZScan(ctx context.Context, req *immuschema.ZScanRequest) (*immuschema.ZEntries, error)

	History(ctx context.Context, req *immuschema.HistoryRequest) (*immuschema.Entries, error)

	ZScanExt(ctx context.Context, options *immuschema.ZScanRequest) (*schema.ZItemExtList, error)
	HistoryExt(ctx context.Context, options *immuschema.HistoryRequest) (sl *schema.ItemExtList, err error)
	Feats(ctx context.Context, in *empty.Empty) (*schema.Features, error)

	Health(ctx context.Context) (*immuschema.HealthResponse, error)

	VerifiedGetExt(ctx context.Context, key []byte) (*schema.VerifiableItemExt, error)
	VerifiedGetExtSince(ctx context.Context, key []byte, tx uint64) (*schema.VerifiableItemExt, error)
	VerifiedGetExtAt(ctx context.Context, key []byte, tx uint64) (itemExt *schema.VerifiableItemExt, err error)

	SetFile(ctx context.Context, key []byte, filePath string) (*immuschema.TxMetadata, error)
	GetFile(ctx context.Context, key []byte, filePath string) (*immuschema.Entry, error)

	Connect() (err error)

	// streams
	StreamSet(ctx context.Context, kvs []*stream.KeyValue) (*immuschema.TxMetadata, error)
	StreamGet(ctx context.Context, k *immuschema.KeyRequest) (*immuschema.Entry, error)
	StreamVerifiedSet(ctx context.Context, kvs []*stream.KeyValue) (*immuschema.TxMetadata, error)
	StreamVerifiedGet(ctx context.Context, req *immuschema.VerifiableGetRequest) (*immuschema.Entry, error)
	StreamScan(ctx context.Context, req *immuschema.ScanRequest) (*immuschema.Entries, error)
	StreamZScan(ctx context.Context, req *immuschema.ZScanRequest) (*immuschema.ZEntries, error)
	StreamHistory(ctx context.Context, req *immuschema.HistoryRequest) (*immuschema.Entries, error)
	StreamExecAll(ctx context.Context, req *stream.ExecAllRequest) (*immuschema.TxMetadata, error)
}

LcClientIf ...

type LcClientOption

type LcClientOption func(*LcClient)

func ApiKey

func ApiKey(apiKey string) LcClientOption

func ClientConn

func ClientConn(clientConn *grpc.ClientConn) LcClientOption

func DialOptions

func DialOptions(dopts []grpc.DialOption) LcClientOption

func Dir

func Dir(c string) LcClientOption

func Host

func Host(c string) LcClientOption

func Logger

func Logger(logger logger.Logger) LcClientOption

func MetadataPairs added in v0.9.2

func MetadataPairs(metadataPairs []string) LcClientOption

func Port

func Port(port int) LcClientOption

func ServerSigningPubKey added in v0.9.1

func ServerSigningPubKey(serverSigningPubKey *ecdsa.PublicKey) LcClientOption

func ServiceClient

func ServiceClient(serviceClient schema.LcServiceClient) LcClientOption

func StateService added in v0.9.1

func StateService(rootservice state.StateService) LcClientOption

func TimestampService

func TimestampService(timestampService immuclient.TimestampService) LcClientOption

type LcStateProvider added in v0.9.1

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

func NewLcStateProvider added in v0.9.1

func NewLcStateProvider(client schema.LcServiceClient) *LcStateProvider

func (LcStateProvider) CurrentState added in v0.9.1

type LcUuidProvider

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

func NewLcUUIDProvider

func NewLcUUIDProvider(client schema.LcServiceClient) *LcUuidProvider

func (LcUuidProvider) CurrentUUID

func (r LcUuidProvider) CurrentUUID(ctx context.Context) (string, error)

CurrentUuid issues a Health command to the server, then parses and returns the server UUID from the response metadata

Jump to

Keyboard shortcuts

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