table

package
v3.25.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a set of session instances that may be reused. A Client is safe for use by multiple goroutines simultaneously.

func New

func New(cc grpc.ClientConnInterface, config config.Config) *Client

func (*Client) Close

func (c *Client) Close(ctx context.Context) (err error)

Close deletes all stored sessions inside Client. It also stops all underlying timers and goroutines. It returns first error occurred during stale sessions' deletion. Note that even on error it calls Close() on each session.

func (*Client) CloseSession added in v3.5.2

func (c *Client) CloseSession(ctx context.Context, s Session) error

CloseSession provides the most effective way of session closing instead of plain session.Close(). CloseSession must be fast. If necessary, can be async.

func (*Client) CreateSession added in v3.24.1

func (c *Client) CreateSession(ctx context.Context, opts ...table.Option) (_ table.ClosableSession, err error)

func (*Client) Do added in v3.24.1

func (c *Client) Do(ctx context.Context, op table.Operation, opts ...table.Option) (err error)

Do provide the best effort for execute operation Do implements internal busy loop until one of the following conditions is met: - deadline was canceled or deadlined - retry operation returned nil as error Warning: if deadline without deadline or cancellation func Retry will be worked infinite

func (*Client) DoTx added in v3.24.1

func (c *Client) DoTx(ctx context.Context, op table.TxOperation, opts ...table.Option) (err error)

func (*Client) Get

func (c *Client) Get(ctx context.Context) (s Session, err error)

Get returns first idle session from the Client and removes it from there. If no items stored in Client it creates new one returns it.

func (*Client) Put

func (c *Client) Put(ctx context.Context, s Session) (err error)

Put returns session to the Client for further reuse. If Client is already closed Put() calls s.Close(ctx) and returns errClosedClient. If Client is overflow calls s.Close(ctx) and returns errSessionPoolOverflow.

Note that Put() must be called only once after being created or received by Get() or Take() calls. In other way it will produce unexpected behavior or panic.

type Session

type Session interface {
	table.ClosableSession

	Status() string
	OnClose(f func(ctx context.Context))
	// contains filtered or unexported methods
}

type SessionBuilder

type SessionBuilder func(context.Context) (Session, error)

SessionBuilder is the interface that holds logic of creating sessions.

type SessionProvider

type SessionProvider interface {
	// Get returns alive idle session or creates new one.
	Get(context.Context) (Session, error)

	// Put takes no longer needed session for reuse or deletion depending
	// on implementation.
	// Put must be fast, if necessary must be async
	Put(context.Context, Session) (err error)

	// CloseSession provides the most effective way of session closing
	// instead of plain session.Close().
	// CloseSession must be fast. If necessary, can be async.
	CloseSession(ctx context.Context, s Session) error
}

SessionProvider is the interface that holds session lifecycle logic.

func SingleSession

func SingleSession(s Session) SessionProvider

SingleSession returns SessionProvider that uses only given session during retries.

type SessionProviderFunc

type SessionProviderFunc struct {
	OnGet func(context.Context) (Session, error)
	OnPut func(context.Context, Session) error
}

func (SessionProviderFunc) CloseSession

func (f SessionProviderFunc) CloseSession(ctx context.Context, s Session) error

func (SessionProviderFunc) Get

func (SessionProviderFunc) Put

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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