Documentation
¶
Index ¶
- Constants
- Variables
- func BuildToken(database string, token string) []byte
- func GetServerUuid(ctx context.Context, immuClient schema.ImmuServiceClient) (string, error)
- func NewHomedirService() *homedirService
- type BatchRequest
- type HomedirService
- type ImmuClient
- type MTLsOptions
- type Options
- func (o *Options) Bind() string
- func (o *Options) String() string
- func (o *Options) WithAddress(address string) *Options
- func (o *Options) WithAuth(authEnabled bool) *Options
- func (o *Options) WithConfig(config string) *Options
- func (o *Options) WithDialOptions(dialOptions *[]grpc.DialOption) *Options
- func (o *Options) WithDir(dir string) *Options
- func (o *Options) WithHealthCheckRetries(retries int) *Options
- func (o *Options) WithLogFileName(filename string) *Options
- func (o *Options) WithMTLs(MTLs bool) *Options
- func (o *Options) WithMTLsOptions(MTLsOptions MTLsOptions) *Options
- func (o *Options) WithMetrics(start bool) *Options
- func (o *Options) WithPasswordReader(pr c.PasswordReader) *Options
- func (o *Options) WithPidPath(path string) *Options
- func (o *Options) WithPort(port int) *Options
- func (o *Options) WithPrometheusHost(host string) *Options
- func (o *Options) WithPrometheusPort(port string) *Options
- func (o *Options) WithTokenFileName(tokenFileName string) *Options
- func (o *Options) WithTokenService(tkns TokenService) *Options
- type RootService
- type TimestampService
- type TokenService
- type VerifiedIndex
- type VerifiedItem
Constants ¶
const AdminTokenFileSuffix = "_admin"
AdminTokenFileSuffix is the suffix used for the token file name
Variables ¶
var ( ErrAlreadyConnected = errors.New("already connected") ErrNotConnected = errors.New("not connected") ErrHealthCheckFailed = errors.New("health check failed") )
Errors related to Client connection and health check
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 ...
Functions ¶
func BuildToken ¶ added in v0.7.0
func GetServerUuid ¶
GetServerUuid issues a Health command to the server, then parses and returns the server UUID from the response metadata
func NewHomedirService ¶ added in v0.7.0
func NewHomedirService() *homedirService
Types ¶
type BatchRequest ¶
BatchRequest batch request payload
type HomedirService ¶ added in v0.7.0
type ImmuClient ¶
type ImmuClient interface {
Disconnect() error
IsConnected() bool
WaitForHealthCheck(ctx context.Context) (err 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
PrintTree(ctx context.Context) (*schema.Tree, error)
CurrentRoot(ctx context.Context) (*schema.Root, error)
Set(ctx context.Context, key []byte, value []byte) (*schema.Index, error)
SafeSet(ctx context.Context, key []byte, value []byte) (*VerifiedIndex, error)
RawSafeSet(ctx context.Context, key []byte, value []byte) (*VerifiedIndex, error)
Get(ctx context.Context, key []byte) (*schema.StructuredItem, error)
SafeGet(ctx context.Context, key []byte, opts ...grpc.CallOption) (*VerifiedItem, error)
RawSafeGet(ctx context.Context, key []byte, opts ...grpc.CallOption) (*VerifiedItem, error)
Scan(ctx context.Context, prefix []byte) (*schema.StructuredItemList, error)
ZScan(ctx context.Context, set []byte) (*schema.StructuredItemList, error)
ByIndex(ctx context.Context, index uint64) (*schema.StructuredItem, error)
RawBySafeIndex(ctx context.Context, index uint64) (*VerifiedItem, error)
IScan(ctx context.Context, pageNumber uint64, pageSize uint64) (*schema.SPage, error)
Count(ctx context.Context, prefix []byte) (*schema.ItemsCount, error)
SetBatch(ctx context.Context, request *BatchRequest) (*schema.Index, error)
GetBatch(ctx context.Context, keys [][]byte) (*schema.StructuredItemList, error)
Inclusion(ctx context.Context, index uint64) (*schema.InclusionProof, error)
Consistency(ctx context.Context, index uint64) (*schema.ConsistencyProof, error)
History(ctx context.Context, key []byte) (*schema.StructuredItemList, error)
Reference(ctx context.Context, reference []byte, key []byte) (*schema.Index, error)
SafeReference(ctx context.Context, reference []byte, key []byte) (*VerifiedIndex, error)
ZAdd(ctx context.Context, set []byte, score float64, key []byte) (*schema.Index, error)
SafeZAdd(ctx context.Context, set []byte, score float64, key []byte) (*VerifiedIndex, error)
Dump(ctx context.Context, writer io.WriteSeeker) (int64, error)
HealthCheck(ctx context.Context) error
WithOptions(options *Options) *immuClient
WithLogger(logger logger.Logger) *immuClient
WithRootService(rs RootService) *immuClient
WithTimestampService(ts TimestampService) *immuClient
WithClientConn(clientConn *grpc.ClientConn) *immuClient
WithServiceClient(serviceClient schema.ImmuServiceClient) *immuClient
WithTokenService(tokenService TokenService) *immuClient
GetServiceClient() *schema.ImmuServiceClient
GetOptions() *Options
SetupDialOptions(options *Options) *[]grpc.DialOption
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
DatabaseList(ctx context.Context) (*schema.DatabaseListResponse, error)
// contains filtered or unexported methods
}
ImmuClient ...
func NewImmuClient ¶
func NewImmuClient(options *Options) (c ImmuClient, err error)
NewImmuClient ...
type MTLsOptions ¶
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) 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
DialOptions *[]grpc.DialOption
Config string
TokenFileName string
CurrentDatabase string
PasswordReader c.PasswordReader
Tkns TokenService
Metrics bool
PidPath string
PrometheusHost string
PrometheusPort string
LogFileName string
}
Options client options
func (*Options) WithAddress ¶
WithAddress sets address
func (*Options) WithConfig ¶
WithConfig sets config file name
func (*Options) WithDialOptions ¶
func (o *Options) WithDialOptions(dialOptions *[]grpc.DialOption) *Options
WithDialOptions sets dialOptions
func (*Options) WithHealthCheckRetries ¶
WithHealthCheckRetries sets healt check retries
func (*Options) WithLogFileName ¶ added in v0.7.0
WithLogFileName set log file name
func (*Options) WithMTLsOptions ¶
func (o *Options) WithMTLsOptions(MTLsOptions MTLsOptions) *Options
WithMTLsOptions sets MTLsOptions
func (*Options) WithMetrics ¶ added in v0.7.0
WithMetrics set if metrics should start
func (*Options) WithPasswordReader ¶ added in v0.7.0
func (o *Options) WithPasswordReader(pr c.PasswordReader) *Options
WithPasswordReader sets the password reader for the client
func (*Options) WithPidPath ¶ added in v0.7.0
WithPidPath set pid file path
func (*Options) WithPrometheusHost ¶ added in v0.7.0
WithPrometheusHost set prometheus host
func (*Options) WithPrometheusPort ¶ added in v0.7.0
WithPrometheusPort set prometheus port
func (*Options) WithTokenFileName ¶
WithTokenFileName sets token file name
func (*Options) WithTokenService ¶ added in v0.7.0
func (o *Options) WithTokenService(tkns TokenService) *Options
WithTokenService sets the TokenService for the client
type RootService ¶
type RootService interface {
GetRoot(ctx context.Context, databasename string) (*schema.Root, error)
SetRoot(root *schema.Root, databasename string) error
}
RootService the root service interface
func NewRootService ¶
func NewRootService(immuC schema.ImmuServiceClient, cache cache.Cache, logger logger.Logger) RootService
NewRootService ...
type TimestampService ¶
TimestampService the timestamp service interface
func NewTimestampService ¶
func NewTimestampService(ts timestamp.TsGenerator) TimestampService
NewTimestampService ...
type TokenService ¶ added in v0.7.0
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)
}
type VerifiedIndex ¶
VerifiedIndex ...
func (*VerifiedIndex) String ¶
func (vi *VerifiedIndex) String() string