primitive

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	// Create is called to create the session
	Create(ctx context.Context, instance *Instance) error

	// Close is called to close the primitive
	Close(ctx context.Context, instance *Instance) error

	// Delete is called to delete the primitive
	Delete(ctx context.Context, instance *Instance) error
}

Handler provides session management for a primitive implementation

type Instance

type Instance struct {
	Name    Name
	Session *Session
	// contains filtered or unexported fields
}

Instance is a primitive instance

func NewInstance

func NewInstance(ctx context.Context, name Name, session *Session, handler Handler) (*Instance, error)

NewInstance creates a new primitive instance

func (*Instance) Close

func (i *Instance) Close(ctx context.Context) error

Close closes the instance

func (*Instance) Delete

func (i *Instance) Delete(ctx context.Context) error

Delete deletes the instance

func (*Instance) DoClose

func (i *Instance) DoClose(ctx context.Context, f func(ctx context.Context, conn *grpc.ClientConn, header *headers.RequestHeader) (*headers.ResponseHeader, interface{}, error)) error

DoClose sends a session close request

func (*Instance) DoCommand

func (i *Instance) DoCommand(ctx context.Context, f func(ctx context.Context, conn *grpc.ClientConn, header *headers.RequestHeader) (*headers.ResponseHeader, interface{}, error)) (interface{}, error)

DoCommand sends a session command request

func (*Instance) DoCommandStream

func (i *Instance) DoCommandStream(
	ctx context.Context,
	f func(ctx context.Context, conn *grpc.ClientConn, header *headers.RequestHeader) (interface{}, error),
	responseFunc func(interface{}) (*headers.ResponseHeader, interface{}, error)) (<-chan interface{}, error)

DoCommandStream sends a session command stream request

func (*Instance) DoCreate

func (i *Instance) DoCreate(ctx context.Context, f func(ctx context.Context, conn *grpc.ClientConn, header *headers.RequestHeader) (*headers.ResponseHeader, interface{}, error)) error

DoCreate sends a create session request

func (*Instance) DoQuery

func (i *Instance) DoQuery(ctx context.Context, f func(ctx context.Context, conn *grpc.ClientConn, header *headers.RequestHeader) (*headers.ResponseHeader, interface{}, error)) (interface{}, error)

DoQuery sends a session query request

func (*Instance) DoQueryStream

func (i *Instance) DoQueryStream(
	ctx context.Context,
	f func(ctx context.Context, conn *grpc.ClientConn, header *headers.RequestHeader) (interface{}, error),
	responseFunc func(interface{}) (*headers.ResponseHeader, interface{}, error)) (<-chan interface{}, error)

DoQueryStream sends a session query stream request

type Metadata

type Metadata struct {
	// Type is the primitive type
	Type Type

	// Name is the primitive name
	Name Name
}

Metadata is primitive metadata

type MetadataOption

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

MetadataOption implements a session metadata option

func WithNamespace

func WithNamespace(namespace string) MetadataOption

WithNamespace returns a metadata option limiting a query by namespace

func WithPrimitiveType

func WithPrimitiveType(primitiveType Type) MetadataOption

WithPrimitiveType returns a metadata option limiting a query by primitive type

type Name

type Name struct {
	// Namespace is the namespace within which the database is stored
	Namespace string
	// Database is the database in which the primitive is stored
	Database string
	// Scope is the application scope in which the primitive is stored
	Scope string
	// Name is the simple name of the primitive
	Name string
}

Name is a qualified primitive name consisting of Namespace, Database, Application, and Name

func NewName

func NewName(namespace string, group string, scope string, name string) Name

NewName returns a qualified primitive name with the given namespace, group, application, and name

func (Name) String

func (n Name) String() string

type Partition

type Partition struct {
	// ID is the partition identifier
	ID int

	// Address is the partition address
	Address net.Address
}

Partition is the ID and address for a partition

type Primitive

type Primitive interface {
	// Name returns the fully namespaced primitive name
	Name() Name

	// Close closes the primitive
	Close(ctx context.Context) error

	// Delete deletes the primitive state from the cluster
	Delete(ctx context.Context) error
}

Primitive is the base interface for primitives

type Session

type Session struct {
	Partition int
	Timeout   time.Duration
	SessionID uint64
	// contains filtered or unexported fields
}

Session maintains the session for a primitive

func NewSession

func NewSession(ctx context.Context, partition Partition, opts ...SessionOption) (*Session, error)

NewSession creates a new Session for the given partition name is the name of the primitive handler is the primitive's session handler

func (*Session) Close

func (s *Session) Close() error

Close closes the session

type SessionOption

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

SessionOption implements a session option

func WithSessionTimeout

func WithSessionTimeout(timeout time.Duration) SessionOption

WithSessionTimeout returns a session SessionOption to configure the session timeout

type Stream

type Stream struct {
	ID uint64
	// contains filtered or unexported fields
}

Stream manages the context for a single response stream within a session

func (*Stream) Close

func (s *Stream) Close()

Close closes the stream

type Type

type Type string

Type is the type of a primitive

Jump to

Keyboard shortcuts

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