repl

package
v1.1.92 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JSONArray means array struct [] in json
	JSONArray = iota
	// JSONMap means map struct {} in json
	JSONMap
	// JSONString means string "" in json
	JSONString
	// JSONInt means int in json
	JSONInt
	// JSONEnd means nothing valuable found
	JSONEnd
)
View Source
const (
	CommandSetTypeLocal   = "local"
	CommandSetTypeRemote  = "remote"
	CommandSetTypeAccount = "account"
)
View Source
const (
	LOCAL = iota
	ACCOUNT
)

Variables

This section is empty.

Functions

func ExecuteFromFile

func ExecuteFromFile(fileName string)

ExecuteFromFile execute from file which contains a sequence of command

func Repl

func Repl(opts ...Option)

Repl start a shell for user

func UnexpectedEventCb

func UnexpectedEventCb(pc *Client) func(data interface{})

UnexpectedEventCb returns a function to deal with un listened event

Types

type Account

type Account struct {
	Username       string                       `json:"Username"`
	Aliases        map[string][]string          `json:"Aliases"`
	CmdSets        map[string]map[string]string `json:"CmdSets"`
	CurrentSet     string                       `json:"CurrentSet"`
	CurrentSetType int                          `json:"CurrentSetType"`
}

Account is cli's account

func (*Account) Load

func (a *Account) Load() (bool, error)

Load loads account

func (*Account) Save

func (a *Account) Save() error

Save saves account

type CliLogger

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

CliLogger log by *ishell.Shell

func NewCliLogger

func NewCliLogger(shell *ishell.Shell) *CliLogger

NewCliLogger creates a clilog object pointer

func (CliLogger) Debug

func (l CliLogger) Debug(v ...interface{})

Debug comment

func (CliLogger) Debugf

func (l CliLogger) Debugf(format string, v ...interface{})

Debugf comment

func (CliLogger) Debugln

func (l CliLogger) Debugln(v ...interface{})

Debugln comment

func (CliLogger) Error

func (l CliLogger) Error(v ...interface{})

Error comment

func (CliLogger) Errorf

func (l CliLogger) Errorf(format string, v ...interface{})

Errorf comment

func (CliLogger) Errorln

func (l CliLogger) Errorln(v ...interface{})

Errorln comment

func (CliLogger) Fatal

func (l CliLogger) Fatal(v ...interface{})

Fatal comment

func (CliLogger) Fatalf

func (l CliLogger) Fatalf(format string, v ...interface{})

Fatalf comment

func (CliLogger) Fatalln

func (l CliLogger) Fatalln(v ...interface{})

Fatalln comment

func (CliLogger) Info

func (l CliLogger) Info(v ...interface{})

Info comment

func (CliLogger) Infof

func (l CliLogger) Infof(format string, v ...interface{})

Infof comment

func (CliLogger) Infoln

func (l CliLogger) Infoln(v ...interface{})

Infoln comment

func (CliLogger) Panic

func (l CliLogger) Panic(v ...interface{})

Panic comment

func (CliLogger) Panicf

func (l CliLogger) Panicf(format string, v ...interface{})

Panicf comment

func (CliLogger) Panicln

func (l CliLogger) Panicln(v ...interface{})

Panicln comment

func (CliLogger) Print

func (l CliLogger) Print(v ...interface{})

Print comment

func (CliLogger) Printf

func (l CliLogger) Printf(format string, v ...interface{})

Printf comment

func (CliLogger) Println

func (l CliLogger) Println(v ...interface{})

Println comment

func (CliLogger) Trace

func (l CliLogger) Trace(v ...interface{})

Trace comment

func (CliLogger) Tracef

func (l CliLogger) Tracef(format string, v ...interface{})

Tracef comment

func (CliLogger) Traceln

func (l CliLogger) Traceln(v ...interface{})

Traceln comment

func (CliLogger) Warn

func (l CliLogger) Warn(v ...interface{})

Warn comment

func (CliLogger) Warnf

func (l CliLogger) Warnf(format string, v ...interface{})

Warnf comment

func (CliLogger) Warning

func (l CliLogger) Warning(v ...interface{})

Warning comment

func (CliLogger) Warningf

func (l CliLogger) Warningf(format string, v ...interface{})

Warningf comment

func (CliLogger) Warningln

func (l CliLogger) Warningln(v ...interface{})

Warningln comment

func (CliLogger) Warnln

func (l CliLogger) Warnln(v ...interface{})

Warnln comment

type Client

type Client struct {
	connector.Connector
	IncomingMsgChan chan *message.Message
}

Client struct

func NewClient

func NewClient() *Client

NewClient returns a new client with the auto documentation route.

func (*Client) Connect

func (pc *Client) Connect(addr string) error

Connect to server

func (*Client) ConnectedStatus

func (pc *Client) ConnectedStatus() bool

ConnectedStatus returns the the current connection status

func (*Client) Disconnect

func (pc *Client) Disconnect()

Disconnect the client

func (*Client) MsgChannel

func (pc *Client) MsgChannel() chan *message.Message

MsgChannel return the incoming message channel

func (*Client) SendNotify

func (pc *Client) SendNotify(route string, data []byte) error

SendNotify sends a notify to the server

func (*Client) SendRequest

func (pc *Client) SendRequest(route string, data []byte) (uint, error)

SendRequest sends a request to the server

type ErrorReader

type ErrorReader func(int64) string

ErrorReader is the type for ErrorReader

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
	Print(v ...interface{})
	Println(v ...interface{})
}

Logger comment

type Option

type Option func(*Options)

Option defines a type for option, an option is a func operate options.NodeOptions

func WithBranch

func WithBranch(branch uint32) Option

func WithCodec

func WithCodec(codec codec.Codec) Option

func WithComponents

func WithComponents(components *component.Components) Option

WithComponents sets the Components

func WithDictionary

func WithDictionary(dictionary message.Dictionary) Option

func WithEnableUnexpected

func WithEnableUnexpected(enableUnexpected bool) Option

func WithErrorReader

func WithErrorReader(errorReader ErrorReader) Option

WithErrorReader customize error reader, which can read error msg from code

func WithIsWebSocket added in v1.1.32

func WithIsWebSocket(isWebSocket bool) Option

WithIsWebSocket indicates whether current node WebSocket is enabled

func WithPrettyJSON

func WithPrettyJSON(prettyJSON bool) Option

WithPrettyJSON sets replied JSON pretty

func WithReasonReader

func WithReasonReader(reasonReader ReasonReader) Option

WithReasonReader 显示错误码对应的文本的option

func WithRedisClient

func WithRedisClient(redisOptions *redis.Options) Option

WithRedisClient sets the redis client options

func WithSerializer

func WithSerializer(serializer serializer.Serializer) Option

WithSerializerType customizes application serializer, which automatically Marshal and UnMarshal handler payload

func WithVersion

func WithVersion(version string) Option

func WithWebSocketCompression added in v1.1.32

func WithWebSocketCompression(webSocketCompression bool) Option

func WithWebSocketPath added in v1.1.34

func WithWebSocketPath(wsPath string) Option

WithWebSocketPath sets root path for ws

type Options

type Options struct {
	IsWebSocket          bool
	WebSocketPath        string
	WebSocketCompression bool
	PrettyJSON           bool
	Serializer           serializer.Serializer // serializer for connector
	ErrorReader          ErrorReader
	ReasonReader         ReasonReader
	Components           *component.Components
	RedisOptions         *redis.Options
	Codec                codec.Codec
	Dictionary           message.Dictionary
	Branch               uint32
	EnableUnexpected     bool
}

Options contains some configurations for current node

type ReasonReader

type ReasonReader func(int64) string

Jump to

Keyboard shortcuts

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