Documentation
¶
Index ¶
- func Login(conn Conn, userID, password string) error
- type BehaviorOptions
- func (f *BehaviorOptions) GetFetchSize() int
- func (f *BehaviorOptions) GetParallelism() int
- func (f *BehaviorOptions) GetPriority() int
- func (f *BehaviorOptions) GetTryReconnectNums() int
- func (f *BehaviorOptions) SetFetchSize(fs int) *BehaviorOptions
- func (f *BehaviorOptions) SetParallelism(p int) *BehaviorOptions
- func (f *BehaviorOptions) SetPriority(p int) *BehaviorOptions
- func (f *BehaviorOptions) SetSqlStd(sqlStd SqlStdEnum) *BehaviorOptions
- func (f *BehaviorOptions) SetTryReconnectNums(n int) *BehaviorOptions
- type Conn
- type ErrorType
- type ServerError
- type ServerErrorCode
- type SqlStdEnum
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BehaviorOptions ¶
type BehaviorOptions struct {
// Priority specifies the priority of the task
Priority *int
// Parallelism specifies the parallelism of the task
Parallelism *int
// FetchSize specifies the fetchSize of the task
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 times to try reconnecting
TryReconnectNums *int
// UsePython specifies whether the session uses a Python parser
UsePython bool
// SqlStd specifies which SQL standard should be used for the session.
SqlStd SqlStdEnum
// if enable SCRAM login verify
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) GetFetchSize ¶
func (f *BehaviorOptions) GetFetchSize() int
GetFetchSize gets the fetchSize of the task.
func (*BehaviorOptions) GetParallelism ¶
func (f *BehaviorOptions) GetParallelism() int
GetParallelism gets the parallelism of the task.
func (*BehaviorOptions) GetPriority ¶
func (f *BehaviorOptions) GetPriority() int
GetPriority gets the priority of the task.
func (*BehaviorOptions) GetTryReconnectNums ¶ added in v3.0.3
func (f *BehaviorOptions) GetTryReconnectNums() int
func (*BehaviorOptions) SetFetchSize ¶
func (f *BehaviorOptions) SetFetchSize(fs int) *BehaviorOptions
SetFetchSize sets the fetchSize of the task.
func (*BehaviorOptions) SetParallelism ¶
func (f *BehaviorOptions) SetParallelism(p int) *BehaviorOptions
SetParallelism sets the parallelism of the task.
func (*BehaviorOptions) SetPriority ¶
func (f *BehaviorOptions) SetPriority(p int) *BehaviorOptions
SetPriority sets the priority of the task.
func (*BehaviorOptions) SetSqlStd ¶ added in v3.0.4
func (f *BehaviorOptions) SetSqlStd(sqlStd SqlStdEnum) *BehaviorOptions
SetSqlStd sets the SQL standard of the session.
func (*BehaviorOptions) SetTryReconnectNums ¶ added in v3.0.3
func (f *BehaviorOptions) SetTryReconnectNums(n int) *BehaviorOptions
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)
// 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)
// 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 NewConn ¶
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 ¶
NewSimpleConn instantiates a new connection with the addr, which connects to the server and logs in with the userID and pwd.
func NewSimpleConnWithBehavior ¶ added in v3.0.4
func NewSimpleConnWithBehavior(ctx context.Context, address, userID, pwd string, behaviorOpt *BehaviorOptions) (Conn, error)
NewSimpleConnWithBehavior instantiates a new connection with the addr, which connects to the server and logs in with the userID and pwd.
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