View Source
const AdminTokenFileSuffix = "_admin"

    AdminTokenFileSuffix is the suffix used for the token file name

    View Source
    const DefaultDB = "defaultdb"


    View Source
    var (
    	ErrIllegalArguments = errors.New("illegal arguments")
    	ErrAlreadyConnected   = errors.New("already connected")
    	ErrNotConnected       = errors.New("not connected")
    	ErrHealthCheckFailed  = errors.New("health check failed")
    	ErrServerStateIsOlder = errors.New("server state is older than the client one")

      Errors related to Client connection and health check

      View Source
      var (
      	ErrSrvIllegalArguments   = status.Error(codes.InvalidArgument, "illegal arguments")
      	ErrSrvIllegalState       = status.Error(codes.InvalidArgument, "illegal state")
      	ErrSrvEmptyAdminPassword = status.Error(codes.InvalidArgument, "Admin password cannot be empty")

        Server errors mapping


        func BuildToken

        func BuildToken(database string, token string) []byte

        func NewHomedirService

        func NewHomedirService() *homedirService


        type HomedirService

        type HomedirService interface {
        	WriteFileToUserHomeDir(content []byte, pathToFile string) error
        	FileExistsInUserHomeDir(pathToFile string) (bool, error)
        	ReadFileFromUserHomeDir(pathToFile string) (string, error)
        	DeleteFileFromUserHomeDir(pathToFile string) error

        type ImmuClient

        type ImmuClient interface {
        	Disconnect() error
        	IsConnected() bool
        	WaitForHealthCheck(ctx context.Context) (err error)
        	HealthCheck(ctx context.Context) error
        	Connect(ctx context.Context) (clientConn *grpc.ClientConn, err error)
        	Login(ctx context.Context, user []byte, pass []byte) (*schema.LoginResponse, error)
        	Logout(ctx context.Context) error
        	CreateUser(ctx context.Context, user []byte, pass []byte, permission uint32, databasename string) error
        	ListUsers(ctx context.Context) (*schema.UserList, error)
        	ChangePassword(ctx context.Context, user []byte, oldPass []byte, newPass []byte) error
        	ChangePermission(ctx context.Context, action schema.PermissionAction, username string, database string, permissions uint32) error
        	UpdateAuthConfig(ctx context.Context, kind auth.Kind) error
        	UpdateMTLSConfig(ctx context.Context, enabled bool) error
        	WithOptions(options *Options) *immuClient
        	WithLogger(logger logger.Logger) *immuClient
        	WithStateService(rs state.StateService) *immuClient
        	WithClientConn(clientConn *grpc.ClientConn) *immuClient
        	WithServiceClient(serviceClient schema.ImmuServiceClient) *immuClient
        	WithTokenService(tokenService TokenService) *immuClient
        	WithServerSigningPubKey(serverSigningPubKey *ecdsa.PublicKey) *immuClient
        	WithStreamServiceFactory(ssf stream.ServiceFactory) *immuClient
        	GetServiceClient() schema.ImmuServiceClient
        	GetOptions() *Options
        	SetupDialOptions(options *Options) *[]grpc.DialOption
        	DatabaseList(ctx context.Context) (*schema.DatabaseListResponse, error)
        	CreateDatabase(ctx context.Context, d *schema.Database) error
        	UseDatabase(ctx context.Context, d *schema.Database) (*schema.UseDatabaseReply, error)
        	SetActiveUser(ctx context.Context, u *schema.SetActiveUserRequest) error
        	CleanIndex(ctx context.Context, req *emptypb.Empty) error
        	CurrentState(ctx context.Context) (*schema.ImmutableState, error)
        	Set(ctx context.Context, key []byte, value []byte) (*schema.TxMetadata, error)
        	VerifiedSet(ctx context.Context, key []byte, value []byte) (*schema.TxMetadata, error)
        	Get(ctx context.Context, key []byte) (*schema.Entry, error)
        	GetSince(ctx context.Context, key []byte, tx uint64) (*schema.Entry, error)
        	GetAt(ctx context.Context, key []byte, tx uint64) (*schema.Entry, error)
        	VerifiedGet(ctx context.Context, key []byte) (*schema.Entry, error)
        	VerifiedGetSince(ctx context.Context, key []byte, tx uint64) (*schema.Entry, error)
        	VerifiedGetAt(ctx context.Context, key []byte, tx uint64) (*schema.Entry, error)
        	History(ctx context.Context, req *schema.HistoryRequest) (*schema.Entries, error)
        	ZAdd(ctx context.Context, set []byte, score float64, key []byte) (*schema.TxMetadata, error)
        	VerifiedZAdd(ctx context.Context, set []byte, score float64, key []byte) (*schema.TxMetadata, error)
        	ZAddAt(ctx context.Context, set []byte, score float64, key []byte, atTx uint64) (*schema.TxMetadata, error)
        	VerifiedZAddAt(ctx context.Context, set []byte, score float64, key []byte, atTx uint64) (*schema.TxMetadata, error)
        	Scan(ctx context.Context, req *schema.ScanRequest) (*schema.Entries, error)
        	ZScan(ctx context.Context, req *schema.ZScanRequest) (*schema.ZEntries, error)
        	TxByID(ctx context.Context, tx uint64) (*schema.Tx, error)
        	VerifiedTxByID(ctx context.Context, tx uint64) (*schema.Tx, error)
        	TxScan(ctx context.Context, req *schema.TxScanRequest) (*schema.TxList, error)
        	Count(ctx context.Context, prefix []byte) (*schema.EntryCount, error)
        	CountAll(ctx context.Context) (*schema.EntryCount, error)
        	SetAll(ctx context.Context, kvList *schema.SetRequest) (*schema.TxMetadata, error)
        	GetAll(ctx context.Context, keys [][]byte) (*schema.Entries, error)
        	ExecAll(ctx context.Context, in *schema.ExecAllRequest) (*schema.TxMetadata, error)
        	SetReference(ctx context.Context, key []byte, referencedKey []byte) (*schema.TxMetadata, error)
        	VerifiedSetReference(ctx context.Context, key []byte, referencedKey []byte) (*schema.TxMetadata, error)
        	SetReferenceAt(ctx context.Context, key []byte, referencedKey []byte, atTx uint64) (*schema.TxMetadata, error)
        	VerifiedSetReferenceAt(ctx context.Context, key []byte, referencedKey []byte, atTx uint64) (*schema.TxMetadata, error)
        	Dump(ctx context.Context, writer io.WriteSeeker) (int64, error)
        	StreamSet(ctx context.Context, kv []*stream.KeyValue) (*schema.TxMetadata, error)
        	StreamGet(ctx context.Context, k *schema.KeyRequest) (*schema.Entry, error)
        	StreamVerifiedSet(ctx context.Context, kv []*stream.KeyValue) (*schema.TxMetadata, error)
        	StreamVerifiedGet(ctx context.Context, k *schema.VerifiableGetRequest) (*schema.Entry, error)
        	StreamScan(ctx context.Context, req *schema.ScanRequest) (*schema.Entries, error)
        	StreamZScan(ctx context.Context, req *schema.ZScanRequest) (*schema.ZEntries, error)
        	StreamHistory(ctx context.Context, req *schema.HistoryRequest) (*schema.Entries, error)
        	StreamExecAll(ctx context.Context, req *stream.ExecAllRequest) (*schema.TxMetadata, error)
        	// DEPRECATED: Please use CurrentState
        	CurrentRoot(ctx context.Context) (*schema.ImmutableState, error)
        	// DEPRECATED: Please use VerifiedSet
        	SafeSet(ctx context.Context, key []byte, value []byte) (*schema.TxMetadata, error)
        	// DEPRECATED: Please use VerifiedGet
        	SafeGet(ctx context.Context, key []byte, opts ...grpc.CallOption) (*schema.Entry, error)
        	// DEPRECATED: Please use VerifiedZAdd
        	SafeZAdd(ctx context.Context, set []byte, score float64, key []byte) (*schema.TxMetadata, error)
        	// DEPRECATED: Please use VerifiedSetReference
        	SafeReference(ctx context.Context, key []byte, referencedKey []byte) (*schema.TxMetadata, error)

          ImmuClient ...

          func DefaultClient

          func DefaultClient() ImmuClient

            DefaultClient ...

            func NewImmuClient

            func NewImmuClient(options *Options) (c ImmuClient, err error)

              NewImmuClient ...

              type MTLsOptions

              type MTLsOptions struct {
              	Servername  string
              	Pkey        string
              	Certificate string
              	ClientCAs   string

                MTLsOptions mTLS options

                func DefaultMTLsOptions

                func DefaultMTLsOptions() MTLsOptions

                  DefaultMTLsOptions returns the default mTLS options

                  func (MTLsOptions) WithCertificate

                  func (o MTLsOptions) WithCertificate(certificate string) MTLsOptions

                    WithCertificate ...

                    func (MTLsOptions) WithClientCAs

                    func (o MTLsOptions) WithClientCAs(clientCAs string) MTLsOptions

                      WithClientCAs ...

                      func (MTLsOptions) WithPkey

                      func (o MTLsOptions) WithPkey(pkey string) MTLsOptions

                        WithPkey ...

                        func (MTLsOptions) WithServername

                        func (o MTLsOptions) WithServername(servername string) MTLsOptions

                          WithServername ...

                          type Options

                          type Options struct {
                          	Dir                string
                          	Address            string
                          	Port               int
                          	HealthCheckRetries int
                          	MTLs               bool
                          	MTLsOptions        MTLsOptions
                          	Auth               bool
                          	MaxRecvMsgSize     int
                          	DialOptions        *[]grpc.DialOption
                          	Config             string
                          	TokenFileName      string
                          	CurrentDatabase    string
                          	//--> only used by immuclient CLI
                          	PasswordReader c.PasswordReader
                          	Username       string
                          	Password       string
                          	Database       string
                          	Tkns                TokenService
                          	Metrics             bool
                          	PidPath             string
                          	PrometheusHost      string
                          	PrometheusPort      string
                          	LogFileName         string
                          	ServerSigningPubKey string
                          	StreamChunkSize     int

                            Options client options

                            func DefaultOptions

                            func DefaultOptions() *Options

                              DefaultOptions ...

                              func (*Options) Bind

                              func (o *Options) Bind() string

                                Bind concatenates address and port

                                func (*Options) String

                                func (o *Options) String() string

                                func (*Options) WithAddress

                                func (o *Options) WithAddress(address string) *Options

                                  WithAddress sets address

                                  func (*Options) WithAuth

                                  func (o *Options) WithAuth(authEnabled bool) *Options

                                    WithAuth activate/deactivate auth

                                    func (*Options) WithConfig

                                    func (o *Options) WithConfig(config string) *Options

                                      WithConfig sets config file name

                                      func (*Options) WithDatabase

                                      func (o *Options) WithDatabase(database string) *Options

                                        WithDatabase sets the database for the client

                                        func (*Options) WithDialOptions

                                        func (o *Options) WithDialOptions(dialOptions *[]grpc.DialOption) *Options

                                          WithDialOptions sets dialOptions

                                          func (*Options) WithDir

                                          func (o *Options) WithDir(dir string) *Options

                                            WithDir sets program file folder

                                            func (*Options) WithHealthCheckRetries

                                            func (o *Options) WithHealthCheckRetries(retries int) *Options

                                              WithHealthCheckRetries sets healt check retries

                                              func (*Options) WithLogFileName

                                              func (o *Options) WithLogFileName(filename string) *Options

                                                WithLogFileName set log file name

                                                func (*Options) WithMTLs

                                                func (o *Options) WithMTLs(MTLs bool) *Options

                                                  WithMTLs activate/deactivate MTLs

                                                  func (*Options) WithMTLsOptions

                                                  func (o *Options) WithMTLsOptions(MTLsOptions MTLsOptions) *Options

                                                    WithMTLsOptions sets MTLsOptions

                                                    func (*Options) WithMaxRecvMsgSize

                                                    func (o *Options) WithMaxRecvMsgSize(maxRecvMsgSize int) *Options

                                                      MaxRecvMsgSize max recv msg size in bytes

                                                      func (*Options) WithMetrics

                                                      func (o *Options) WithMetrics(start bool) *Options

                                                        WithMetrics set if metrics should start

                                                        func (*Options) WithPassword

                                                        func (o *Options) WithPassword(password string) *Options

                                                          WithPassword sets the password for the client

                                                          func (*Options) WithPasswordReader

                                                          func (o *Options) WithPasswordReader(pr c.PasswordReader) *Options

                                                            WithPasswordReader sets the password reader for the client

                                                            func (*Options) WithPidPath

                                                            func (o *Options) WithPidPath(path string) *Options

                                                              WithPidPath set pid file path

                                                              func (*Options) WithPort

                                                              func (o *Options) WithPort(port int) *Options

                                                                WithPort sets port

                                                                func (*Options) WithPrometheusHost

                                                                func (o *Options) WithPrometheusHost(host string) *Options

                                                                  WithPrometheusHost set prometheus host

                                                                  func (*Options) WithPrometheusPort

                                                                  func (o *Options) WithPrometheusPort(port string) *Options

                                                                    WithPrometheusPort set prometheus port

                                                                    func (*Options) WithServerSigningPubKey

                                                                    func (o *Options) WithServerSigningPubKey(serverSigningPubKey string) *Options

                                                                      WithServerSigningPubKey sets the public key. If presents server state signature verification is enabled

                                                                      func (*Options) WithStreamChunkSize

                                                                      func (o *Options) WithStreamChunkSize(streamChunkSize int) *Options

                                                                        WithStreamChunkSize set the chunk size

                                                                        func (*Options) WithTokenFileName

                                                                        func (o *Options) WithTokenFileName(tokenFileName string) *Options

                                                                          WithTokenFileName sets token file name

                                                                          func (*Options) WithTokenService

                                                                          func (o *Options) WithTokenService(tkns TokenService) *Options

                                                                            WithTokenService sets the TokenService for the client

                                                                            func (*Options) WithUsername

                                                                            func (o *Options) WithUsername(username string) *Options

                                                                              WithUsername sets the username for the client

                                                                              type TimestampService

                                                                              type TimestampService interface {
                                                                              	GetTime() time.Time

                                                                                TimestampService the timestamp service interface

                                                                                func NewTimestampService

                                                                                func NewTimestampService(ts timestamp.TsGenerator) TimestampService

                                                                                  NewTimestampService ...

                                                                                  type TokenService

                                                                                  type TokenService interface {
                                                                                  	SetToken(database string, token string) error
                                                                                  	WithHds(hds HomedirService) TokenService
                                                                                  	WithTokenFileName(tfn string) TokenService
                                                                                  	IsTokenPresent() (bool, error)
                                                                                  	DeleteToken() error
                                                                                  	GetToken() (string, error)
                                                                                  	GetDatabase() (string, error)

                                                                                  func NewTokenService

                                                                                  func NewTokenService() TokenService

                                                                                    NewTokenService ...


                                                                                    Path Synopsis
                                                                                    Package clienttest ...
                                                                                    Package clienttest ...