dialer

package
v3.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 24 Imported by: 3 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Login added in v3.0.3

func Login(conn Conn, userID, password string) error

Types

type BehaviorOptions

type BehaviorOptions struct {
	// Priority specifies the priority of the task.
	// Nil uses the SDK default value.
	Priority *int
	// Parallelism specifies the parallelism of the task.
	// Nil uses the SDK default value.
	Parallelism *int
	// FetchSize specifies the fetchSize of the task.
	// Nil uses the SDK default value.
	FetchSize *int
	// Timeout specifies how long a request waits for the server response.
	Timeout time.Duration
	// NetTimeout specifies the network-layer timeout budget used for TCP
	// connect, Linux TCP_USER_TIMEOUT and keepalive probing. Zero uses the SDK
	// defaults.
	NetTimeout time.Duration

	// Whether to enable load balancing.
	// If true, connect to the address with the fewest connections.
	LoadBalance bool

	// Whether to enable high availability.
	// If true, the connection tries addr first, then retries HighAvailabilitySites in a shuffled order.
	EnableHighAvailability bool

	// Available only when EnableHighAvailability is true.
	HighAvailabilitySites []string

	// If true, the address will be reconnected util the server is ready.
	Reconnect bool

	// IsReverseStreaming specifies whether the job is a reverse stream subscription
	IsReverseStreaming bool
	// IsClearSessionMemory specifies whether to clear session memory after the job
	IsClearSessionMemory bool

	// TryReconnectNums specifies the number of reconnection attempts.
	// Nil means reconnect indefinitely; any non-positive value is invalid.
	TryReconnectNums *int

	// LeaderConvergenceTimeout limits how long one request waits for repeated
	// structured NotLeader responses after the first NotLeader is received.
	// It is not a total request deadline: earlier targetless HA retries are not
	// included. Zero uses the SDK default of 60 seconds.
	LeaderConvergenceTimeout time.Duration

	// UsePython specifies whether the session uses a Python parser
	UsePython bool

	// SqlStd specifies which SQL standard should be used for the session.
	SqlStd SqlStdEnum

	// EnableScram specifies whether SCRAM login is required.
	// When false, login still tries SCRAM first and falls back to password login
	// if the server or user does not support SCRAM.
	EnableScram bool
}

BehaviorOptions helps you configure behavior identity. Refer to https://github.com/dolphindb/Tutorials_CN/blob/master/api_protocol.md#254-%E8%A1%8C%E4%B8%BA%E6%A0%87%E8%AF%86 for more details.

func (*BehaviorOptions) Validate added in v3.1.0

func (f *BehaviorOptions) Validate() error

Validate checks whether the behavior options are internally consistent.

type Conn

type Conn interface {
	net.Conn

	// Connect connects to dolphindb server
	Connect() error
	// GetLocalAddress gets the local address with the connection
	GetLocalAddress() string

	//  RefreshTimeout resets the timeout of the connection
	RefreshTimeout(t time.Duration)
	// GetSession gets the session id of the connection
	GetSession() string
	// Close closes the connection with server
	Close() error
	// IsClosed checks whether the connection is closed
	IsClosed() bool
	// IsConnected checks whether the connection is connected
	IsConnected() bool

	// GetUserID gets the userID
	GetUserID() string
	// SetUserID sets the userID
	SetUserID(userID string)
	// GetPassword gets the password
	GetPassword() string
	// SetPassword sets the password
	SetPassword(password string)

	// RunScript sends script to dolphindb and returns the execution result
	RunScript(s string) (model.DataForm, error)
	// RunScriptWithTrace sends script to dolphindb and returns execution trace information.
	RunScriptWithTrace(s string) (model.DataForm, *ExecutionTrace, error)
	// RunFile sends script from a specific file to dolphindb and returns the execution result
	RunFile(path string) (model.DataForm, error)
	// RunFunc sends function request to dolphindb and returns the execution result.
	// See DolphinDB function and command references: https://www.dolphindb.cn/cn/help/130/FunctionsandCommands/FunctionReferences/index.html
	RunFunc(s string, args []model.DataForm) (model.DataForm, error)
	// RunFuncWithTrace sends function request to dolphindb and returns execution trace information.
	RunFuncWithTrace(s string, args []model.DataForm) (model.DataForm, *ExecutionTrace, error)
	// Upload sends local objects to dolphindb server and the specified variable is generated on the dolphindb
	Upload(vars map[string]model.DataForm) (model.DataForm, error)
	// GetTCPConn returns the TCPConn
	GetTCPConn() *net.TCPConn

	// for inner use
	GetReader() protocol.Reader

	ConnLogin(userID, password string) error
	// contains filtered or unexported methods
}

Conn is the interface of DolphinDB conn.

func Dial added in v3.1.0

func Dial(address, userID, pwd string, behaviorOpt *BehaviorOptions) (Conn, error)

Dial creates a connection, connects to the server and logs in with the provided credentials. It uses context.Background internally until the connect path supports cancellation end-to-end.

func NewConn

func NewConn(ctx context.Context, addr string, behaviorOpt *BehaviorOptions) (Conn, error)

NewConn instantiates a new connection with the addr. BehaviorOpt will affect every request sent by conn. You can input opts to configure conn.

func NewSimpleConn deprecated

func NewSimpleConn(_ context.Context, address, userID, pwd string) (Conn, error)

Deprecated: use Dial instead.

func NewSimpleConnWithBehavior deprecated added in v3.0.4

func NewSimpleConnWithBehavior(_ context.Context, address, userID, pwd string, behaviorOpt *BehaviorOptions) (Conn, error)

Deprecated: use Dial instead.

type ErrorType

type ErrorType int
const (
	IGNORE ErrorType = iota
	UNKNOWN
	NEW_LEADER
	UNKNOWN_LEADER
	NODE_NOT_AVAIL
	NO_INITIALIZED
	LOGIN_REQUIRED
	UNEXPECT
)

type ExecutionTrace added in v3.1.0

type ExecutionTrace struct {
	Failovers []FailoverTrace
}

ExecutionTrace describes what happened while executing a request.

type FailoverReason added in v3.1.0

type FailoverReason string

FailoverReason describes why the client moved from one node to another.

const (
	FailoverReasonUnknown                FailoverReason = ""
	FailoverReasonNotLeader              FailoverReason = "NotLeader"
	FailoverReasonLeaderConvergenceWait  FailoverReason = "LeaderConvergenceWait"
	FailoverReasonHighAvailability       FailoverReason = "HighAvailability"
	FailoverReasonServerDirectedFallback FailoverReason = "ServerDirectedFallback"
)

type FailoverTrace added in v3.1.0

type FailoverTrace struct {
	Reason FailoverReason
	From   string
	To     string
	Err    string
}

FailoverTrace records one request-level failover observed during execution.

type ServerError added in v3.0.5

type ServerError struct {
	Code    ServerErrorCode
	Raw     string
	Detail  string
	Address string
}

ServerError preserves the original server response while exposing structured fields.

func AsServerError added in v3.0.5

func AsServerError(err error) (*ServerError, bool)

AsServerError extracts a structured server error from err. It also understands the legacy plain-string error format for compatibility.

func (*ServerError) Error added in v3.0.5

func (e *ServerError) Error() string

func (*ServerError) Is added in v3.0.5

func (e *ServerError) Is(code ServerErrorCode) bool

Is reports whether the server error matches the specified code.

func (*ServerError) SuggestsFailover added in v3.0.5

func (e *ServerError) SuggestsFailover() bool

SuggestsFailover reports whether retrying on another node may succeed.

func (*ServerError) TargetAddress added in v3.0.5

func (e *ServerError) TargetAddress() (string, bool)

TargetAddress returns the server-directed target node when present.

type ServerErrorCode added in v3.0.5

type ServerErrorCode string

ServerErrorCode identifies a structured server-side response error.

const (
	ServerErrUnknown          ServerErrorCode = ""
	ServerErrNotLeader        ServerErrorCode = "NotLeader"
	ServerErrUnknownLeader    ServerErrorCode = "UnknownLeader"
	ServerErrDataNodeNotAvail ServerErrorCode = "DataNodeNotAvail"
)

type SqlStdEnum added in v3.0.4

type SqlStdEnum int

SqlStandard specifies which SQL standard should be used for the session. The numeric values must stay compatible with the existing DolphinDB protocol: DolphinDB=0, Oracle=1, MySQL=2.

const (
	// SqlStdDolphinDB uses DolphinDB SQL semantics.
	SqlStdDolphinDB SqlStdEnum = 0
	// SqlStdOracle uses Oracle-compatible SQL semantics.
	SqlStdOracle SqlStdEnum = 1
	// SqlStdMySQL uses MySQL-compatible SQL semantics.
	SqlStdMySQL SqlStdEnum = 2
	// SqlStdDefault keeps the default DolphinDB SQL semantics.
	SqlStdDefault = SqlStdDolphinDB
)

func (SqlStdEnum) String added in v3.0.4

func (s SqlStdEnum) String() string

Directories

Path Synopsis
Package protocol contains functions for zero-copy casting between typed slices and byte slices.
Package protocol contains functions for zero-copy casting between typed slices and byte slices.

Jump to

Keyboard shortcuts

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