connector

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: BSD-2-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TCPNetwork  = "tcp"
	UnixNetwork = "unix"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryConnector

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

BinaryConnector implements Connector interface for a connection that sends and receives data via IPROTO.

func NewBinaryConnector

func NewBinaryConnector(conn tarantool.Connector) *BinaryConnector

NewBinaryConnector creates a new BinaryConnector object. The object will close the tarantool.Connector argument in Close() call.

func (*BinaryConnector) Close

func (conn *BinaryConnector) Close() error

Close closes the tarantool.Connector created from.

func (*BinaryConnector) Eval

func (conn *BinaryConnector) Eval(expr string, args []interface{},
	opts RequestOpts) ([]interface{}, error)

Eval sends an eval request.

type ConnectOpts

type ConnectOpts struct {
	// Network is a characteristic of a connection like "type" ("tcp" and
	// "unix" are used).
	Network string
	// Address of an instance.
	Address string
	// Username of the tarantool user.
	Username string
	// Password of the user.
	Password string
	// Ssl options for a connection.
	Ssl SslOpts
}

ConnectOpts describes options for a connection to a tarantool instance.

type Connector

type Connector interface {
	Evaler
	Close() error
}

Connector is an interface that wraps all method required for a connector.

func Connect

func Connect(opts ConnectOpts) (Connector, error)

Connect connects to the tarantool instance according to options.

type EvalPlainTextOpts

type EvalPlainTextOpts struct {
	ReadTimeout  time.Duration
	PushCallback func(interface{})
	ResData      interface{}
}

type Evaler

type Evaler interface {
	// Eval passes Lua expression for evaluation.
	Eval(expr string, args []interface{}, opts RequestOpts) ([]interface{}, error)
}

Eval is an interface that wraps Eval method.

type PlainTextEvalRes

type PlainTextEvalRes struct {
	DataEncBase64 string `yaml:"data_enc"`
}

type Protocol

type Protocol int

Protocol defines a set of supported protocols for a connect.

const (
	// IPROTO.
	BinaryProtocol Protocol = iota
	// Plain text messages.
	TextProtocol
)

func GetProtocol

func GetProtocol(reader io.Reader) (Protocol, error)

GetProtocol gets a protocol name from the reader greeting. See: https://github.com/tarantool/tarantool/blob/8dcefeb2bf5291487496d168cb81f5b6082a2af0/test/unit/xrow.cc#L92-L123

func ParseProtocol

func ParseProtocol(greeting string) (Protocol, bool)

ParseProtocol parses a protocol name from a Tarantool greeting.

func (Protocol) String

func (protocol Protocol) String() string

String returns a string representation of the protocol.

type RequestOpts

type RequestOpts struct {
	// PushCallback is the cb that will be called when a "push" message is received.
	PushCallback func(interface{})
	// ReadTimeout timeout for the operation.
	ReadTimeout time.Duration
	// ResData describes the typed result of the operation executed.
	ResData interface{}
}

RequestOpts describes the parameters of a request to be executed.

type SslOpts added in v1.0.0

type SslOpts struct {
	// KeyFile is a path to a private SSL key file.
	KeyFile string
	// CertFile is a path to an SSL certificate file.
	CertFile string
	// CaFile is a path to a trusted certificate authorities (CA) file.
	CaFile string
	// Ciphers is a colon-separated (:) list of SSL cipher suites the
	// connection can use.
	Ciphers string
}

SslOpts is a way to configure SSL connection.

type TextConnector

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

TextConnector implements Connector interface for a connection that sends and receives data as a plain text.

func NewTextConnector

func NewTextConnector(conn net.Conn) *TextConnector

NewTextConnector creates a new TextConnector object. The object will close the net.Conn argument in Close() call.

func (*TextConnector) Close

func (conn *TextConnector) Close() error

Close closes the net.Conn created from.

func (*TextConnector) Eval

func (conn *TextConnector) Eval(expr string, args []interface{},
	opts RequestOpts) ([]interface{}, error)

Eval sends an eval request.

Jump to

Keyboard shortcuts

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