Documentation ¶
Overview ¶
Copyright 2022 CodeNotary, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2022 CodeNotary, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func NewClient() *immuClient
- func NewImmuClient(options *Options) (*immuClient, error)
- type GetOption
- 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) WithDatabase(database 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) WithHeartBeatFrequency(heartBeatFrequency time.Duration) *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) WithMaxRecvMsgSize(maxRecvMsgSize int) *Options
- func (o *Options) WithMetrics(start bool) *Options
- func (o *Options) WithPassword(password string) *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) WithServerSigningPubKey(serverSigningPubKey string) *Options
- func (o *Options) WithStreamChunkSize(streamChunkSize int) *Options
- func (o *Options) WithTokenFileName(tokenFileName string) *Options
- func (o *Options) WithUsername(username string) *Options
- type TimestampService
- type Tx
Constants ¶
const AdminTokenFileSuffix = "_admin"
AdminTokenFileSuffix is the suffix used for the token file name
const DefaultDB = "defaultdb"
const SQLPrefix byte = 2
Variables ¶
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") ErrSessionAlreadyOpen = errors.New("session already opened") )
Errors related to Client connection and health check
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") ErrWriteOnlyTXNotAllowed = status.Error(codes.InvalidArgument, "write only transaction not allowed") )
Server errors mapping
Functions ¶
func NewImmuClient ¶
NewImmuClient ... Deprecated: use NewClient instead.
Types ¶
type GetOption ¶ added in v1.3.0
type GetOption func(req *schema.KeyRequest) error
func AtRevision ¶ added in v1.3.0
type ImmuClient ¶
type ImmuClient interface { Disconnect() error IsConnected() bool // Deprecated: grpc retry mechanism can be implemented with WithConnectParams dialOption WaitForHealthCheck(ctx context.Context) (err error) HealthCheck(ctx context.Context) error // Deprecated: connection is handled in OpenSession Connect(ctx context.Context) (clientConn *grpc.ClientConn, err error) // Deprecated: use OpenSession Login(ctx context.Context, user []byte, pass []byte) (*schema.LoginResponse, error) // Deprecated: use CloseSession Logout(ctx context.Context) error OpenSession(ctx context.Context, user []byte, pass []byte, database string) (err error) CloseSession(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 // Deprecated: will be removed in future versions UpdateAuthConfig(ctx context.Context, kind auth.Kind) error // Deprecated: will be removed in future versions UpdateMTLSConfig(ctx context.Context, enabled bool) error WithOptions(options *Options) *immuClient WithLogger(logger logger.Logger) *immuClient WithStateService(rs state.StateService) *immuClient // Deprecated: will be removed in future versions WithClientConn(clientConn *grpc.ClientConn) *immuClient // Deprecated: will be removed in future versions WithServiceClient(serviceClient schema.ImmuServiceClient) *immuClient WithTokenService(tokenService 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) DatabaseListV2(ctx context.Context) (*schema.DatabaseListResponseV2, error) CreateDatabase(ctx context.Context, d *schema.DatabaseSettings) error CreateDatabaseV2(ctx context.Context, database string, settings *schema.DatabaseNullableSettings) (*schema.CreateDatabaseResponse, error) LoadDatabase(ctx context.Context, r *schema.LoadDatabaseRequest) (*schema.LoadDatabaseResponse, error) UnloadDatabase(ctx context.Context, r *schema.UnloadDatabaseRequest) (*schema.UnloadDatabaseResponse, error) DeleteDatabase(ctx context.Context, r *schema.DeleteDatabaseRequest) (*schema.DeleteDatabaseResponse, error) UseDatabase(ctx context.Context, d *schema.Database) (*schema.UseDatabaseReply, error) UpdateDatabase(ctx context.Context, settings *schema.DatabaseSettings) error UpdateDatabaseV2(ctx context.Context, database string, settings *schema.DatabaseNullableSettings) (*schema.UpdateDatabaseResponse, error) GetDatabaseSettings(ctx context.Context) (*schema.DatabaseSettings, error) GetDatabaseSettingsV2(ctx context.Context) (*schema.DatabaseSettingsResponse, error) SetActiveUser(ctx context.Context, u *schema.SetActiveUserRequest) error FlushIndex(ctx context.Context, cleanupPercentage float32, synced bool) (*schema.FlushIndexResponse, error) CompactIndex(ctx context.Context, req *empty.Empty) error Health(ctx context.Context) (*schema.DatabaseHealthResponse, error) CurrentState(ctx context.Context) (*schema.ImmutableState, error) Set(ctx context.Context, key []byte, value []byte) (*schema.TxHeader, error) VerifiedSet(ctx context.Context, key []byte, value []byte) (*schema.TxHeader, error) ExpirableSet(ctx context.Context, key []byte, value []byte, expiresAt time.Time) (*schema.TxHeader, error) Get(ctx context.Context, key []byte, opts ...GetOption) (*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) GetAtRevision(ctx context.Context, key []byte, rev int64) (*schema.Entry, error) VerifiedGet(ctx context.Context, key []byte, opts ...GetOption) (*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) VerifiedGetAtRevision(ctx context.Context, key []byte, rev int64) (*schema.Entry, error) History(ctx context.Context, req *schema.HistoryRequest) (*schema.Entries, error) ZAdd(ctx context.Context, set []byte, score float64, key []byte) (*schema.TxHeader, error) VerifiedZAdd(ctx context.Context, set []byte, score float64, key []byte) (*schema.TxHeader, error) ZAddAt(ctx context.Context, set []byte, score float64, key []byte, atTx uint64) (*schema.TxHeader, error) VerifiedZAddAt(ctx context.Context, set []byte, score float64, key []byte, atTx uint64) (*schema.TxHeader, 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) TxByIDWithSpec(ctx context.Context, req *schema.TxRequest) (*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.TxHeader, error) GetAll(ctx context.Context, keys [][]byte) (*schema.Entries, error) Delete(ctx context.Context, req *schema.DeleteKeysRequest) (*schema.TxHeader, error) ExecAll(ctx context.Context, in *schema.ExecAllRequest) (*schema.TxHeader, error) SetReference(ctx context.Context, key []byte, referencedKey []byte) (*schema.TxHeader, error) VerifiedSetReference(ctx context.Context, key []byte, referencedKey []byte) (*schema.TxHeader, error) SetReferenceAt(ctx context.Context, key []byte, referencedKey []byte, atTx uint64) (*schema.TxHeader, error) VerifiedSetReferenceAt(ctx context.Context, key []byte, referencedKey []byte, atTx uint64) (*schema.TxHeader, error) Dump(ctx context.Context, writer io.WriteSeeker) (int64, error) StreamSet(ctx context.Context, kv []*stream.KeyValue) (*schema.TxHeader, error) StreamGet(ctx context.Context, k *schema.KeyRequest) (*schema.Entry, error) StreamVerifiedSet(ctx context.Context, kv []*stream.KeyValue) (*schema.TxHeader, 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.TxHeader, error) ExportTx(ctx context.Context, req *schema.ExportTxRequest) (schema.ImmuService_ExportTxClient, error) ReplicateTx(ctx context.Context) (schema.ImmuService_ReplicateTxClient, error) SQLExec(ctx context.Context, sql string, params map[string]interface{}) (*schema.SQLExecResult, error) SQLQuery(ctx context.Context, sql string, params map[string]interface{}, renewSnapshot bool) (*schema.SQLQueryResult, error) ListTables(ctx context.Context) (*schema.SQLQueryResult, error) DescribeTable(ctx context.Context, tableName string) (*schema.SQLQueryResult, error) VerifyRow(ctx context.Context, row *schema.Row, table string, pkVals []*schema.SQLValue) error NewTx(ctx context.Context) (Tx, error) }
ImmuClient ...
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 MaxRecvMsgSize int DialOptions []grpc.DialOption Config string TokenFileName string CurrentDatabase string //--> used by immuclient CLI and sql stdlib package PasswordReader c.PasswordReader Username string Password string Database string //<-- Metrics bool PidPath string LogFileName string ServerSigningPubKey string StreamChunkSize int HeartBeatFrequency time.Duration }
Options client options
func (*Options) WithAddress ¶
WithAddress sets address
func (*Options) WithConfig ¶
WithConfig sets config file name
func (*Options) WithDatabase ¶ added in v0.9.2
WithDatabase sets the database for the client
func (*Options) WithDialOptions ¶
func (o *Options) WithDialOptions(dialOptions []grpc.DialOption) *Options
WithDialOptions sets dialOptions
func (*Options) WithHealthCheckRetries ¶
WithHealthCheckRetries sets healt check retries
func (*Options) WithHeartBeatFrequency ¶ added in v1.2.0
WithHeartBeatFrequency set the keep alive message frequency
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) WithMaxRecvMsgSize ¶ added in v0.8.1
MaxRecvMsgSize max recv msg size in bytes
func (*Options) WithMetrics ¶ added in v0.7.0
WithMetrics set if metrics should start
func (*Options) WithPassword ¶ added in v0.9.2
WithPassword sets the password for the client
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) WithServerSigningPubKey ¶ added in v0.9.0
WithServerSigningPubKey sets the public key. If presents server state signature verification is enabled
func (*Options) WithStreamChunkSize ¶ added in v0.9.2
WithStreamChunkSize set the chunk size
func (*Options) WithTokenFileName ¶
WithTokenFileName sets token file name
func (*Options) WithUsername ¶ added in v0.9.2
WithUsername sets the username for the client
type TimestampService ¶
TimestampService the timestamp service interface
func NewTimestampService ¶
func NewTimestampService(ts timestamp.TsGenerator) TimestampService
NewTimestampService ...
type Tx ¶ added in v1.2.0
type Tx interface { Commit(ctx context.Context) (*schema.CommittedSQLTx, error) Rollback(ctx context.Context) error SQLExec(ctx context.Context, sql string, params map[string]interface{}) error SQLQuery(ctx context.Context, sql string, params map[string]interface{}) (*schema.SQLQueryResult, error) }