client

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package client is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var InvalidSubscribeResult = SubscribeResult{
	LogEntry: varlogpb.InvalidLogEntry(),
	Error:    errors.New("invalid subscribe result"),
}

Functions

This section is empty.

Types

type Kind

type Kind interface {
	*LogClient | *ManagementClient

	// Target returns target storage node.
	Target() varlogpb.StorageNode
	// contains filtered or unexported methods
}

Kind is a generic type for clients managed by the Manager.

type LogClient

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

func (*LogClient) Append

func (c *LogClient) Append(ctx context.Context, tpid types.TopicID, lsid types.LogStreamID, data [][]byte, backups ...varlogpb.StorageNode) ([]snpb.AppendResult, error)

Append stores data to the log stream specified with the topicID and the logStreamID. The backup indicates the storage nodes that have backup replicas of that log stream. It returns valid GLSN if the append completes successfully.

func (*LogClient) LogStreamMetadata

func (c *LogClient) LogStreamMetadata(ctx context.Context, tpid types.TopicID, lsid types.LogStreamID) (varlogpb.LogStreamDescriptor, error)

func (*LogClient) Subscribe

func (c *LogClient) Subscribe(ctx context.Context, tpid types.TopicID, lsid types.LogStreamID, begin, end types.GLSN) (<-chan SubscribeResult, error)

Subscribe gets log entries continuously from the storage node. It guarantees that LLSNs of log entries taken are sequential.

func (*LogClient) SubscribeTo

func (c *LogClient) SubscribeTo(ctx context.Context, tpid types.TopicID, lsid types.LogStreamID, begin, end types.LLSN) (<-chan SubscribeResult, error)

func (*LogClient) Target

func (c *LogClient) Target() varlogpb.StorageNode

Target returns connected storage node.

func (*LogClient) TrimDeprecated

func (c *LogClient) TrimDeprecated(ctx context.Context, tpid types.TopicID, glsn types.GLSN) error

TrimDeprecated deletes log entries greater than or equal to given GLSN in the storage node. The number of deleted log entries are returned.

type ManagementClient

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

func (*ManagementClient) AddLogStreamReplica

func (c *ManagementClient) AddLogStreamReplica(ctx context.Context, tpid types.TopicID, lsid types.LogStreamID, path string) error

func (*ManagementClient) Close

func (c *ManagementClient) Close() error

Close closes connection to the storage node. Deprecated: Use `Manager[*ManagementClient]`.

func (*ManagementClient) GetMetadata

func (*ManagementClient) RemoveLogStream

func (c *ManagementClient) RemoveLogStream(ctx context.Context, tpid types.TopicID, lsid types.LogStreamID) error

func (*ManagementClient) Seal

func (c *ManagementClient) Seal(ctx context.Context, tpid types.TopicID, lsid types.LogStreamID, lastCommittedGLSN types.GLSN) (varlogpb.LogStreamStatus, types.GLSN, error)

func (*ManagementClient) Sync

func (c *ManagementClient) Sync(ctx context.Context, tpid types.TopicID, logStreamID types.LogStreamID, backupStorageNodeID types.StorageNodeID, backupAddress string, lastGLSN types.GLSN) (*snpb.SyncStatus, error)

func (*ManagementClient) Target

func (*ManagementClient) Trim

func (c *ManagementClient) Trim(ctx context.Context, topicID types.TopicID, lastGLSN types.GLSN) (map[types.LogStreamID]error, error)

func (*ManagementClient) Unseal

type Manager

type Manager[T Kind] struct {
	// contains filtered or unexported fields
}

Manager manages clients typed Kind.

func NewManager

func NewManager[T Kind](opts ...ManagerOption) (*Manager[T], error)

NewManager creates a Manager.

func (*Manager[T]) Close

func (mgr *Manager[T]) Close() (err error)

Close closes all clients managed by the Manager.

func (*Manager[T]) CloseClient

func (mgr *Manager[T]) CloseClient(snid types.StorageNodeID) error

CloseClient closes a client identified by the argument snid.

func (*Manager[T]) Get

func (mgr *Manager[T]) Get(snid types.StorageNodeID) (T, error)

Get returns the client identified by the argument snid. It returns an error if the client does not exist.

func (*Manager[T]) GetByAddress

func (mgr *Manager[T]) GetByAddress(addr string) (T, error)

func (*Manager[T]) GetOrConnect

func (mgr *Manager[T]) GetOrConnect(ctx context.Context, snid types.StorageNodeID, addr string) (T, error)

GetOrConnect returns the client identified by the argument snid. It tries to connect the server using the argument addr if the client does not exist. It returns an error if the existing client has an address other than the argument addr or trial of the connection fails.

type ManagerOption

type ManagerOption interface {
	// contains filtered or unexported methods
}

func WithClusterID

func WithClusterID(cid types.ClusterID) ManagerOption

func WithDefaultGRPCDialOptions

func WithDefaultGRPCDialOptions(defaultGRPCDialOptions ...grpc.DialOption) ManagerOption

func WithLogger

func WithLogger(logger *zap.Logger) ManagerOption

type MockStorageNodeManagementClient

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

MockStorageNodeManagementClient is a mock of StorageNodeManagementClient interface.

func NewMockStorageNodeManagementClient

func NewMockStorageNodeManagementClient(ctrl *gomock.Controller) *MockStorageNodeManagementClient

NewMockStorageNodeManagementClient creates a new mock instance.

func (*MockStorageNodeManagementClient) AddLogStreamReplica

func (m *MockStorageNodeManagementClient) AddLogStreamReplica(arg0 context.Context, arg1 types.TopicID, arg2 types.LogStreamID, arg3 string) error

AddLogStreamReplica mocks base method.

func (*MockStorageNodeManagementClient) Close

Close mocks base method.

func (*MockStorageNodeManagementClient) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockStorageNodeManagementClient) GetMetadata

GetMetadata mocks base method.

func (*MockStorageNodeManagementClient) RemoveLogStream

func (m *MockStorageNodeManagementClient) RemoveLogStream(arg0 context.Context, arg1 types.TopicID, arg2 types.LogStreamID) error

RemoveLogStream mocks base method.

func (*MockStorageNodeManagementClient) Seal

Seal mocks base method.

func (*MockStorageNodeManagementClient) Sync

Sync mocks base method.

func (*MockStorageNodeManagementClient) Target

Target mocks base method.

func (*MockStorageNodeManagementClient) Trim

Trim mocks base method.

func (*MockStorageNodeManagementClient) Unseal

Unseal mocks base method.

type MockStorageNodeManagementClientMockRecorder

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

MockStorageNodeManagementClientMockRecorder is the mock recorder for MockStorageNodeManagementClient.

func (*MockStorageNodeManagementClientMockRecorder) AddLogStreamReplica

func (mr *MockStorageNodeManagementClientMockRecorder) AddLogStreamReplica(arg0, arg1, arg2, arg3 interface{}) *gomock.Call

AddLogStreamReplica indicates an expected call of AddLogStreamReplica.

func (*MockStorageNodeManagementClientMockRecorder) Close

Close indicates an expected call of Close.

func (*MockStorageNodeManagementClientMockRecorder) GetMetadata

func (mr *MockStorageNodeManagementClientMockRecorder) GetMetadata(arg0 interface{}) *gomock.Call

GetMetadata indicates an expected call of GetMetadata.

func (*MockStorageNodeManagementClientMockRecorder) RemoveLogStream

func (mr *MockStorageNodeManagementClientMockRecorder) RemoveLogStream(arg0, arg1, arg2 interface{}) *gomock.Call

RemoveLogStream indicates an expected call of RemoveLogStream.

func (*MockStorageNodeManagementClientMockRecorder) Seal

func (mr *MockStorageNodeManagementClientMockRecorder) Seal(arg0, arg1, arg2, arg3 interface{}) *gomock.Call

Seal indicates an expected call of Seal.

func (*MockStorageNodeManagementClientMockRecorder) Sync

func (mr *MockStorageNodeManagementClientMockRecorder) Sync(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call

Sync indicates an expected call of Sync.

func (*MockStorageNodeManagementClientMockRecorder) Target

Target indicates an expected call of Target.

func (*MockStorageNodeManagementClientMockRecorder) Trim

func (mr *MockStorageNodeManagementClientMockRecorder) Trim(arg0, arg1, arg2 interface{}) *gomock.Call

Trim indicates an expected call of Trim.

func (*MockStorageNodeManagementClientMockRecorder) Unseal

func (mr *MockStorageNodeManagementClientMockRecorder) Unseal(arg0, arg1, arg2, arg3 interface{}) *gomock.Call

Unseal indicates an expected call of Unseal.

type StorageNodeManagementClient

type StorageNodeManagementClient interface {
	Target() varlogpb.StorageNode
	GetMetadata(ctx context.Context) (*snpb.StorageNodeMetadataDescriptor, error)
	AddLogStreamReplica(ctx context.Context, topicID types.TopicID, logStreamID types.LogStreamID, path string) error
	RemoveLogStream(ctx context.Context, topicID types.TopicID, logStreamID types.LogStreamID) error
	Seal(ctx context.Context, topicID types.TopicID, logStreamID types.LogStreamID, lastCommittedGLSN types.GLSN) (varlogpb.LogStreamStatus, types.GLSN, error)
	Unseal(ctx context.Context, topicID types.TopicID, logStreamID types.LogStreamID, replicas []varlogpb.LogStreamReplica) error
	Sync(ctx context.Context, topicID types.TopicID, logStreamID types.LogStreamID, backupStorageNodeID types.StorageNodeID, backupAddress string, lastGLSN types.GLSN) (*snpb.SyncStatus, error)
	Trim(ctx context.Context, topicID types.TopicID, lastGLSN types.GLSN) (map[types.LogStreamID]error, error)
	Close() error
}

func NewManagementClient

func NewManagementClient(ctx context.Context, clusterID types.ClusterID, address string, _ *zap.Logger) (StorageNodeManagementClient, error)

type SubscribeResult

type SubscribeResult struct {
	varlogpb.LogEntry
	Error error
}

Jump to

Keyboard shortcuts

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