connect

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: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HistoryFileName = ".tarantool_history"

	MaxLivePrefixIndent = 15
	MaxHistoryLines     = 10000
)

Variables

View Source
var (
	ControlLeftBytes  []byte
	ControlRightBytes []byte
)

Functions

func AddStmtPart

func AddStmtPart(stmt, part string, validator Validator) (string, bool)

AddStmtPart adds a new part of the statement. It returns a result statement and true if the statement is already completed.

func ChangeLanguage

func ChangeLanguage(evaler connector.Evaler, lang Language) error

ChangeLanguage changes a language for a connection.

func Connect

func Connect(connectCtx ConnectCtx, connOpts connector.ConnectOpts) error

Connect establishes a connection to the instance and starts the console.

func Eval

func Eval(connectCtx ConnectCtx, connOpts connector.ConnectOpts, args []string) ([]byte, error)

Eval executes the command on the remote instance (according to args).

Types

type ConnectCtx

type ConnectCtx struct {
	// Username of the tarantool user.
	Username string
	// Password of the tarantool.user.
	Password string
	// SrcFile describes the source of code for the evaluation.
	SrcFile string
	// Language to use for execution.
	Language Language
	// Format to use as an output format.
	Format formatter.Format
	// SslKeyFile is a path to a private SSL key file.
	SslKeyFile string
	// SslCertFile is a path to an SSL certificate file.
	SslCertFile string
	// SslCaFile is a path to a trusted certificate authorities (CA) file.
	SslCaFile string
	// SslCiphers is a colon-separated (:) list of SSL cipher suites the
	// connection can use.
	SslCiphers string
	// Interactive mode is used.
	Interactive bool
	// ConnectTarget contains connection target string: URI or instance name.
	ConnectTarget string
}

ConnectCtx contains information for connecting to the instance.

type Console

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

Console describes the console connected to the tarantool instance.

func NewConsole

func NewConsole(connOpts connector.ConnectOpts, connectCtx ConnectCtx, title string) (*Console,
	error)

NewConsole creates a new console connected to the tarantool instance.

func (*Console) Close

func (console *Console) Close()

Close frees up resources used by the console.

func (*Console) Run

func (console *Console) Run() error

Run starts console.

type EvalFunc

type EvalFunc func(console *Console, funcBodyFmt string, args ...interface{}) (interface{}, error)

EvalFunc defines a function type for evaluating an expression via connection.

type Language

type Language int

Language defines a set of supported languages.

const (
	DefaultLanguage Language = iota
	LuaLanguage
	SQLLanguage
)

func ParseLanguage

func ParseLanguage(str string) (Language, bool)

ParseLanguage parses a language string representation. It supports mixed case letters.

func (Language) String

func (l Language) String() string

String returns a string representation of the language.

type LuaValidator

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

LuaValidator implements ValidateCloser interface for the Lua language.

func NewLuaValidator

func NewLuaValidator() *LuaValidator

NewLuaValidator returns a LuaValidator object.

func (*LuaValidator) Close

func (s *LuaValidator) Close() error

Close closes the Lua validator. It is safe to call it multiple times.

func (*LuaValidator) Validate

func (s *LuaValidator) Validate(str string) bool

Validate returns true if the string is a completed statement for the Lua language.

type SQLValidator

type SQLValidator struct {
}

SQLValidator implements ValidateCloser interface for the SQL language.

func NewSQLValidator

func NewSQLValidator() *SQLValidator

NewSQLValidator return a SQLValidator object.

func (SQLValidator) Close

func (v SQLValidator) Close() error

Close closes the SQL validator. It is safe to call it multiple times.

func (SQLValidator) Validate

func (v SQLValidator) Validate(_ string) bool

Validate always returns true.

type ValidateCloser

type ValidateCloser interface {
	Validator
	// Close closes the validator.
	Close() error
}

ValidateCloser is the interface that wraps basic validate methods for a string statement and Close() methods.

type Validator

type Validator interface {
	// Validate returns true if the string is a completed statement.
	Validate(str string) bool
}

Validator is the interface that wraps basic validate methods for a string statement.

Jump to

Keyboard shortcuts

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