jarviscore

package module
v0.7.212 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2019 License: Apache-2.0 Imports: 35 Imported by: 10

README

jarviscore

Build Status

Jarvis is an open source personal assistant. His name was inspired by the personal assistant of Marvel Iron Man.

Jarvis was originally used to manage multiple servers, making it easier to manage multiple servers.
Jarvis can be used for server management in small companies or groups. It can be used with GitLab for CI, distributed computing, big data processing, visualization, and knowledge base management.

Jarvis includes a chatbot for everyone to control web services.

Jarviscore is the golang implementation of the Jarvis network kernel.


Jarvis Development Log

Come Here

Update
v0.7
  • Improved MessageID
  • Improved Event module to add more event notifications
  • Added Request callback interface
  • Support for message delivery greater than 4MB
  • Improved trust system
  • Added group function to build a new trust group
  • Added Visual Data Service Viewer
  • Added separate note service Note
  • Added NLP server node
  • Added universal crawler node
v0.6
  • Simplified signature verification rules
  • Add event notification interface
  • Added remote call support for scripts
  • Can work on dozens of servers
  • Jarvis for Telegram can support various remote command calls, file transfers, etc.
v0.5
  • Refactored network kernel
  • Added support for goroutine pool
  • Unified server and client transaction processing
  • Implement some test cases
v0.3
  • Upgraded network protocol (not backward compatible)
  • Opened chatbot for telegram
  • Support chat query for telegram
v0.2
  • Data storage switched to AnkaDB
  • Added GraphQL data query
  • Added GraphIQL support
v0.1
  • Complete basic functions and establish a network
  • BTC encryption algorithm
  • leveldb data storage

Documentation

Index

Constants

View Source
const (
	// JarvisResultTypeSend - send
	JarvisResultTypeSend = 1
	// JarvisResultTypeReply - reply
	JarvisResultTypeReply = 2
	// JarvisResultTypeLocalError - error
	JarvisResultTypeLocalError = 3
	// JarvisResultTypeRemoved - removed
	JarvisResultTypeRemoved = 5
	// JarvisResultTypeLocalErrorEnd - error & end
	JarvisResultTypeLocalErrorEnd = 6
)
View Source
const (
	// CtrlTypeScriptFile - scriptfile ctrltype
	CtrlTypeScriptFile = "scriptfile"
)
View Source
const (
	// CtrlTypeScriptFile2 - scriptfile2 ctrltype
	CtrlTypeScriptFile2 = "scriptfile2"
)
View Source
const (
	// CtrlTypeScriptFile3 - scriptfile3 ctrltype
	CtrlTypeScriptFile3 = "scriptfile3"
)

Variables

View Source
var (
	// ErrLoadFileReadSize - loadfile invalid file read size
	ErrLoadFileReadSize = errors.New("loadfile invalid file read size")
	// ErrNotConnectNode - not connect node
	ErrNotConnectNode = errors.New("not connect node")
	// ErrNoCtrlCmd - no ctrl cmd
	ErrNoCtrlCmd = errors.New("no ctrl cmd")
	// ErrCoreDBNoAddr - coredb no addr
	ErrCoreDBNoAddr = errors.New("coredb no addr")
	// ErrSign - sign err
	ErrSign = errors.New("sign err")
	// ErrInvalidAddr - invalid addr
	ErrInvalidAddr = errors.New("invalid addr")
	// ErrInvalidPublishKey - invalid publish key
	ErrInvalidPublishKey = errors.New("invalid publish key")
	// ErrExistCtrlID - exist ctrlid
	ErrExistCtrlID = errors.New("exist ctrlid")
	// ErrAlreadyJoin - already join
	ErrAlreadyJoin = errors.New("already join")
	// ErrNotConnectMe - not connect me
	ErrNotConnectMe = errors.New("not connect me")
	// ErrGRPCPeerFromContext - grpc.peer.FromContext err
	ErrGRPCPeerFromContext = errors.New("grpc.peer.FromContext err")
	// ErrGRPCPeerAddr - grpc.peer.Addr err
	ErrGRPCPeerAddr = errors.New("grpc.peer.Addr err")
	// ErrPublicKeyAddr - public key and address do not match
	ErrPublicKeyAddr = errors.New("public key and address do not match")
	// ErrPublicKeyVerify - public key verify err
	ErrPublicKeyVerify = errors.New("public key verify err")
	// ErrJarvisMsgTimeOut - JarvisMsg timeout
	ErrJarvisMsgTimeOut = errors.New("JarvisMsg timeout")
	// ErrStreamNil - stream nil
	ErrStreamNil = errors.New("stream nil")
	// ErrInvalidMsgType - invalid msgtype
	ErrInvalidMsgType = errors.New("invalid msgtype")
	// ErrServAddrIsMe - servaddr is me
	ErrServAddrIsMe = errors.New("servaddr is me")
	// ErrInvalidEvent - invalid event
	ErrInvalidEvent = errors.New("invalid event")
	// ErrInvalidServAddr - invalid servaddr
	ErrInvalidServAddr = errors.New("invalid servaddr")
	// ErrInvalidNodeName - invalid nodename
	ErrInvalidNodeName = errors.New("invalid nodename")
	// ErrUnknowNode - unknow node
	ErrUnknowNode = errors.New("unknow node")
	// ErrInvalidMsgID - invalid msgid
	ErrInvalidMsgID = errors.New("invalid msgid")
	// ErrDuplicateMsgID - duplicate msgid
	ErrDuplicateMsgID = errors.New("duplicate msgid")
	// ErrInvalidRequestData4Node - invalid requestData4Node
	ErrInvalidRequestData4Node = errors.New("invalid requestData4Node")
	// ErrInvalidRequestNodeData - invalid requestNodeData
	ErrInvalidRequestNodeData = errors.New("invalid requestNodeData")
	// ErrFuncOnSendMsgResultLength - FuncOnSendMsgResult length err
	ErrFuncOnSendMsgResultLength = errors.New("FuncOnSendMsgResult length err")
	// ErrAutoUpdateClosed - auto update closed
	ErrAutoUpdateClosed = errors.New("auto update closed")
	// ErrServAddrConnFail - the servaddr connect fail
	ErrServAddrConnFail = errors.New("the servaddr connect fail")
	// ErrAssertGetNode - assert(GetNode() is not nil)
	ErrAssertGetNode = errors.New("assert(GetNode() is not nil)")
	// ErrDeprecatedNode - deprecated node
	ErrDeprecatedNode = errors.New("deprecated node")
	// ErrNoFileData - no filedata
	ErrNoFileData = errors.New("no filedata")
	// ErrFileDataNoMD5String - filedata no md5tring
	ErrFileDataNoMD5String = errors.New("filedata no md5tring")
	// ErrInvalidFileDataMD5String - invalid filedata md5tring
	ErrInvalidFileDataMD5String = errors.New("invalid filedata md5tring")
	// ErrNotConnectedNode - not connected node
	ErrNotConnectedNode = errors.New("not connected node")
	// ErrInvalidReadFileLength - invalid readfile length
	ErrInvalidReadFileLength = errors.New("invalid readfile length")
	// ErrInvalidSeekFileOffset - invalid seekfile offset
	ErrInvalidSeekFileOffset = errors.New("invalid seekfile offset")
	// ErrNoConnOrInvalidConn - no connection or invalid connection
	ErrNoConnOrInvalidConn = errors.New("no connection or invalid connection")
	// ErrNoCtrlInfo - no ctrlinfo
	ErrNoCtrlInfo = errors.New("no ctrlinfo")
	// ErrCannotFindNodeWithAddr - can not find node with addr
	ErrCannotFindNodeWithAddr = errors.New("can not find node with addr")
	// ErrNoFuncOnFileData - no FuncOnFileData
	ErrNoFuncOnFileData = errors.New("no FuncOnFileData")
	// ErrNoProcMsgResultData - no ProcMsgResultData
	ErrNoProcMsgResultData = errors.New("no ProcMsgResultData")
	// ErrInvalidProcMsgResultData - invalid ProcMsgResultData
	ErrInvalidProcMsgResultData = errors.New("invalid ProcMsgResultData")
	// ErrDuplicateProcMsgResultData - duplicate ProcMsgResultData
	ErrDuplicateProcMsgResultData = errors.New("duplicate ProcMsgResultData")
	// ErrNoCtrl - no ctrl
	ErrNoCtrl = errors.New("no ctrl")
	// ErrUnknownCtrlError - unknown ctrl error
	ErrUnknownCtrlError = errors.New("unknown ctrl error")
	// ErrProcMsgStreamNil - ProcMsgStream return nil
	ErrProcMsgStreamNil = errors.New("ProcMsgStream return nil")
	// ErrIDontTrustYou - I don't trust you
	ErrIDontTrustYou = errors.New("I don't trust you")
	// ErrInvalidTimer - Invalid timer
	ErrInvalidTimer = errors.New("Invalid timer")
	// ErrInvalidTimerFunc - Invalid timer func
	ErrInvalidTimerFunc = errors.New("Invalid timer func")
	// ErrInvalidWait4MyReplyMsgID - Invalid wait for my reply msgid
	ErrInvalidWait4MyReplyMsgID = errors.New("Invalid wait for my reply msgid")
	// ErrInvalidWait4MyReplyAddr - Invalid wait for my reply addr
	ErrInvalidWait4MyReplyAddr = errors.New("Invalid wait for my reply addr")
	// ErrInvalidJarvisMsgReplyStreamDestAddr - Invalid JarvisMsgReplyStream dest addr
	ErrInvalidJarvisMsgReplyStreamDestAddr = errors.New("Invalid JarvisMsgReplyStream dest addr")
	// ErrInvalidJarvisMsgReplyStreamSendMsg - Invalid JarvisMsgReplyStream sendmsg
	ErrInvalidJarvisMsgReplyStreamSendMsg = errors.New("Invalid JarvisMsgReplyStream sendmsg")
	// ErrJarvisMsgReplyStreamSent - JarvisMsgReplyStream has been sent
	ErrJarvisMsgReplyStreamSent = errors.New("JarvisMsgReplyStream has been sent")
	// ErrInvalidJarvisMsgReplyStreamReplyMsgID - Invalid JarvisMsgReplyStream ReplyMsgID
	ErrInvalidJarvisMsgReplyStreamReplyMsgID = errors.New("Invalid JarvisMsgReplyStream ReplyMsgID")
	// ErrInvalidStreamMsgTransferFile2 - Invalid StreamMsg TRANSFER_FILE2
	ErrInvalidStreamMsgTransferFile2 = errors.New("Invalid StreamMsg TRANSFER_FILE2")
	// ErrInvalidCMDStdOutErrErrFile - Invalid CMDStdOutErr errfile
	ErrInvalidCMDStdOutErrErrFile = errors.New("Invalid CMDStdOutErr errfile")
	// ErrCfgInvalidUpdateScript - Invalid UpdateScript
	ErrCfgInvalidUpdateScript = errors.New("Invalid UpdateScript")
)
View Source
var (
	// EventOnNodeConnected - onNodeConnected
	EventOnNodeConnected = "nodeconnected"
	// EventOnIConnectNode - onIConnectNode
	EventOnIConnectNode = "connectnode"
	// EventOnIConnectNodeFail - onIConnectNodeFail
	EventOnIConnectNodeFail = "connectnodefail"
	// EventOnDeprecateNode - onDeprecateNode
	EventOnDeprecateNode = "deprecatenode"

	// EventOnCtrl - OnCtrl
	EventOnCtrl = "onctrl"
	// EventOnCtrlResult - OnCtrlResult
	EventOnCtrlResult = "ctrlresult"
	// EventOnReplyRequestFile - OnReplyRequestFile
	EventOnReplyRequestFile = "replyrequestfile"
	// EventOnRequestFile - OnRequestFile
	EventOnRequestFile = "onrequestfile"
	// EventOnReplyTransferFile - OnReplyTransferFile
	EventOnReplyTransferFile = "replytransferfile"
	// EventOnTransferFile - OnTransferFile
	EventOnTransferFile = "ontransferfile"
	// EventOnUpdateNode - OnUpdateNode
	EventOnUpdateNode = "onupdatenode"

	// EventOnPrivateKey - OnPrivateKey
	EventOnPrivateKey = "privatekey"
)

Functions

func AbsInt64

func AbsInt64(num int64) int64

AbsInt64 - abs int64

func AppendString added in v0.7.130

func AppendString(strs ...string) string

AppendString - append string

func BuildClearLogs added in v0.7.161

func BuildClearLogs(jarvisnode JarvisNode, srcAddr string,
	destAddr string) (*pb.JarvisMsg, error)

BuildClearLogs - build jarvismsg with CLEAR_LOGS

func BuildConnNode

func BuildConnNode(jarvisnode JarvisNode, srcAddr string, destAddr string,
	servaddr string, ni *pb.NodeBaseInfo) (*pb.JarvisMsg, error)

BuildConnNode - build jarvismsg with CONNECT_NODE

func BuildCtrlInfoForScriptFile

func BuildCtrlInfoForScriptFile(filename string, filedata []byte,
	destpath string, scriptName string) (*pb.CtrlInfo, error)

BuildCtrlInfoForScriptFile - build ctrlinfo for scriptfile Deprecated: you can use BuildCtrlInfoForScriptFile3

func BuildCtrlInfoForScriptFile2 added in v0.6.21

func BuildCtrlInfoForScriptFile2(scriptfile *pb.FileData, files []*pb.FileData,
	scriptName string) (*pb.CtrlInfo, error)

BuildCtrlInfoForScriptFile2 - build ctrlinfo for scriptfile Deprecated: you can use BuildCtrlInfoForScriptFile3

func BuildCtrlInfoForScriptFile3 added in v0.7.130

func BuildCtrlInfoForScriptFile3(scriptfile *pb.FileData, endFiles []string,
	scriptName string) (*pb.CtrlInfo, error)

BuildCtrlInfoForScriptFile3 - build ctrlinfo for scriptfile

func BuildCtrlResult

func BuildCtrlResult(jarvisnode JarvisNode, srcAddr string,
	destAddr string, replyMsgID int64, result string,
	errInfo string) (*pb.JarvisMsg, error)

BuildCtrlResult - build jarvismsg with REPLY_CTRL_RESULT

func BuildCtrlResultForCtrl added in v0.7.130

func BuildCtrlResultForCtrl(jarvisnode JarvisNode, srcAddr string, msgid int64,
	str string, errInfo string, msgs []*pb.JarvisMsg) []*pb.JarvisMsg

BuildCtrlResultForCtrl - build CtrlResult for Ctrl

func BuildMultiMsgData added in v0.7.157

func BuildMultiMsgData(jarvisnode JarvisNode, destAddr string, replyMsgID int64,
	multimsg *pb.MultiMsgData) (*pb.JarvisMsg, error)

BuildMultiMsgData - build jarvismsg with MULTI_MSG

func BuildNodeInfo added in v0.6.2

func BuildNodeInfo(jarvisnode JarvisNode, srcAddr string, destAddr string,
	ni *pb.NodeBaseInfo) (*pb.JarvisMsg, error)

BuildNodeInfo - build jarvismsg with NODE_INFO

func BuildOutputMsg added in v0.7.130

func BuildOutputMsg(src *pb.JarvisMsg) (*pb.JarvisMsg, error)

BuildOutputMsg - build a output jarvismsg

func BuildReply2 added in v0.7.130

func BuildReply2(jarvisnode JarvisNode, srcAddr string,
	destAddr string, rt pb.REPLYTYPE, strErr string, replyMsgID int64) (*pb.JarvisMsg, error)

BuildReply2 - build jarvismsg with REPLY2

func BuildReply2ForCtrl added in v0.7.130

func BuildReply2ForCtrl(jarvisnode JarvisNode, srcAddr string, msgid int64,
	replytype pb.REPLYTYPE, info string, msgs []*pb.JarvisMsg) []*pb.JarvisMsg

BuildReply2ForCtrl - build Reply2 for Ctrl

func BuildReplyConn

func BuildReplyConn(jarvisnode JarvisNode, srcAddr string, destAddr string,
	ni *pb.NodeBaseInfo) (*pb.JarvisMsg, error)

BuildReplyConn - build jarvismsg with REPLY_CONNECT

func BuildReplyMsgState added in v0.7.157

func BuildReplyMsgState(jarvisnode JarvisNode, destAddr string, replyMsgID int64,
	msgid int64, state int) (*pb.JarvisMsg, error)

BuildReplyMsgState - build jarvismsg with REPLY_MSG_STATE

func BuildReplyMyNodesVersion added in v0.7.208

func BuildReplyMyNodesVersion(jarvisnode JarvisNode, srcAddr string,
	destAddr string, myNodesVersion string) (*pb.JarvisMsg, error)

BuildReplyMyNodesVersion - build jarvismsg with REPLY_MYNODESVERSION

func BuildReplyRequestFile added in v0.6.12

func BuildReplyRequestFile(jarvisnode JarvisNode, srcAddr string, destAddr string,
	fd *pb.FileData, replyMsgID int64) (*pb.JarvisMsg, error)

BuildReplyRequestFile - build jarvismsg with REPLY_REQUEST_FILE

func BuildReplyRequestFileForCtrl added in v0.7.130

func BuildReplyRequestFileForCtrl(jarvisnode JarvisNode, srcAddr string, msgid int64,
	fd *pb.FileData, msgs []*pb.JarvisMsg) []*pb.JarvisMsg

BuildReplyRequestFileForCtrl - build ReplyRequestFile for Ctrl

func BuildReplyTransferFile added in v0.7.130

func BuildReplyTransferFile(jarvisnode JarvisNode, srcAddr string, destAddr string,
	md5str string, replyMsgID int64) (*pb.JarvisMsg, error)

BuildReplyTransferFile - build jarvismsg with REPLY_TRANSFER_FILE

func BuildRequestCtrl

func BuildRequestCtrl(jarvisnode JarvisNode, srcAddr string,
	destAddr string, ci *pb.CtrlInfo) (*pb.JarvisMsg, error)

BuildRequestCtrl - build jarvismsg with REQUEST_CTRL

func BuildRequestFile added in v0.6.12

func BuildRequestFile(jarvisnode JarvisNode, srcAddr string, destAddr string,
	rf *pb.RequestFile) (*pb.JarvisMsg, error)

BuildRequestFile - build jarvismsg with REQUEST_FILE

func BuildRequestMsgState added in v0.7.157

func BuildRequestMsgState(jarvisnode JarvisNode, destAddr string,
	msgid int64) (*pb.JarvisMsg, error)

BuildRequestMsgState - build jarvismsg with REQUEST_MSG_STATE

func BuildRequestNodes added in v0.6.2

func BuildRequestNodes(jarvisnode JarvisNode, srcAddr string,
	destAddr string) (*pb.JarvisMsg, error)

BuildRequestNodes - build jarvismsg with REQUEST_NODES

func BuildRequestNodes2 added in v0.7.201

func BuildRequestNodes2(jarvisnode JarvisNode, srcAddr string,
	destAddr string, isNeedLocalHost bool, myNodesVersion string, nodesVersion string) (*pb.JarvisMsg, error)

BuildRequestNodes2 - build jarvismsg with REQUEST_NODES2

func BuildTransferFile added in v0.7.130

func BuildTransferFile(jarvisnode JarvisNode, srcAddr string, destAddr string,
	fd *pb.FileData) (*pb.JarvisMsg, error)

BuildTransferFile - build jarvismsg with TRANSFER_FILE

func BuildTransferFile2 added in v0.7.130

func BuildTransferFile2(jarvisnode JarvisNode, srcAddr string, destAddr string,
	fd *pb.FileData) (*pb.JarvisMsg, error)

BuildTransferFile2 - build jarvismsg with TRANSFER_FILE2

func BuildUpdateNode added in v0.7.130

func BuildUpdateNode(jarvisnode JarvisNode, srcAddr string, destAddr string,
	nodetype string, nodetypever string, isOnlyRestart bool) (*pb.JarvisMsg, error)

BuildUpdateNode - build jarvismsg with UPDATENODE

func CountClientGroupProcMsgResultsEnd added in v0.7.130

func CountClientGroupProcMsgResultsEnd(lstResult []*ClientGroupProcMsgResults) int

CountClientGroupProcMsgResultsEnd - count number for end

func CountMD5String added in v0.7.130

func CountMD5String(lst []*pb.FileData) (int64, string, error)

CountMD5String - count MD5 string

func DeepCopy added in v0.7.130

func DeepCopy(src proto.Message, dest proto.Message) error

DeepCopy - deep copy

func GetAbsPath added in v0.7.178

func GetAbsPath(p string) string

GetAbsPath - get absolutely patg

func GetCurPath added in v0.7.178

func GetCurPath() string

GetCurPath - get current path

func GetFileLength added in v0.7.130

func GetFileLength(fn string) (int64, error)

GetFileLength - get file length

func GetMD5String added in v0.7.130

func GetMD5String(buf []byte) string

GetMD5String - md5 buf and return string

func GetNodeBaseInfo added in v0.7.130

func GetNodeBaseInfo(node *coredbpb.NodeInfo) *pb.NodeBaseInfo

GetNodeBaseInfo - get nodebaseinfo from nodeinfo

func GetRealFilename added in v0.7.130

func GetRealFilename(fn string) string

GetRealFilename - get filename

func InitJarvisCore

func InitJarvisCore(cfg *Config, nodeType string, version string)

InitJarvisCore -

func InitPprof added in v0.7.130

func InitPprof(cfg *Config) error

InitPprof - init pprof

func IsClientProcMsgResultEnd added in v0.7.130

func IsClientProcMsgResultEnd(lstResult []*JarvisMsgInfo) bool

IsClientProcMsgResultEnd - is end

func IsLocalHostAddr added in v0.7.130

func IsLocalHostAddr(servaddr string) bool

IsLocalHostAddr - is localhost

func IsMyServAddr added in v0.6.7

func IsMyServAddr(destaddr string, myaddr string) bool

IsMyServAddr - check destaddr is same addr for me

func IsSyncMsg added in v0.7.157

func IsSyncMsg(msg *pb.JarvisMsg) bool

IsSyncMsg - Is it a sync message?

func IsTimeOut

func IsTimeOut(msg *pb.JarvisMsg) bool

IsTimeOut - is JarvisMsg timeout

func IsValidNodeAddr added in v0.7.130

func IsValidNodeAddr(addr string) bool

IsValidNodeAddr - is valid nodeaddr

func IsValidNodeName added in v0.6.12

func IsValidNodeName(nodename string) bool

IsValidNodeName - check node name

func IsValidServAddr added in v0.7.130

func IsValidServAddr(servaddr string) bool

IsValidServAddr - is the server address is valid?

func JSONMsg2Zap added in v0.7.130

func JSONMsg2Zap(key string, src *pb.JarvisMsg) zap.Field

JSONMsg2Zap - I use this interface to output jarvismsg to the zap log.

This interface will hide the long data in jarvismsg.

func MD5File added in v0.7.130

func MD5File(fn string) (string, error)

MD5File - md5 file and return string

func NewCtrlResult added in v0.7.136

func NewCtrlResult(jarvisnode JarvisNode, nodeAddr string, msgid int64, dat proto.Message) (*pb.JarvisMsg, error)

NewCtrlResult - new jarvismsg with REPLY_CTRL_RESULT

func NewErrorMsg added in v0.7.132

func NewErrorMsg(jarvisnode JarvisNode, nodeAddr string, strErr string, replyMsgID int64) *pb.JarvisMsg

NewErrorMsg - new a error JarvisMsg

func ProcFileData added in v0.7.130

func ProcFileData(fn string, onfunc FuncOnFileData) error

ProcFileData - proc filedata

func ProcFileDataWithBuff added in v0.7.130

func ProcFileDataWithBuff(buf []byte, onfunc FuncOnFileData) error

ProcFileDataWithBuff - proc filedata

func PushReply22Msgs added in v0.7.130

func PushReply22Msgs(msgs []*pb.JarvisMsg, jarvisnode JarvisNode, srcAddr string, msgid int64,
	replytype pb.REPLYTYPE, info string) []*pb.JarvisMsg

PushReply22Msgs - push Reply2 to msgs

func ReleaseJarvisCore

func ReleaseJarvisCore() error

ReleaseJarvisCore -

func RunCommand added in v0.7.169

func RunCommand(ctx context.Context, jnode JarvisNode, cmdname string,
	cmd string) (string, string, error)

RunCommand - run command

func SignJarvisMsg

func SignJarvisMsg(privkey *jarviscrypto.PrivateKey, msg *pb.JarvisMsg) error

SignJarvisMsg - sign JarvisMsg

func StoreLocalFile added in v0.6.21

func StoreLocalFile(file *pb.FileData) error

StoreLocalFile - store filedata to local file systems

func StoreLocalFileEx added in v0.7.130

func StoreLocalFileEx(files []*pb.FileData) error

StoreLocalFileEx - store filedata array to local file systems

func VerifyJarvisMsg

func VerifyJarvisMsg(msg *pb.JarvisMsg) error

VerifyJarvisMsg - Verify JarvisMsg

Types

type BaseInfo

type BaseInfo struct {
	Name            string
	BindAddr        string
	ServAddr        string
	Addr            string
	NodeTypeVersion string
	CoreVersion     string
	NodeType        string
}

BaseInfo -

type CMDStdOutErr added in v0.7.169

type CMDStdOutErr struct {
	LenStdOut   int64
	OutFileName string
	ErrFileName string
	// contains filtered or unexported fields
}

CMDStdOutErr - command stdout & stderr

func NewCMDStdOutErr added in v0.7.169

func NewCMDStdOutErr(fnout string, fnerr string) (*CMDStdOutErr, error)

NewCMDStdOutErr - new CMDStdOutErr

func (*CMDStdOutErr) GetStdErr added in v0.7.169

func (out *CMDStdOutErr) GetStdErr() ([]byte, error)

GetStdErr - get stderr

func (*CMDStdOutErr) GetStdOut added in v0.7.169

func (out *CMDStdOutErr) GetStdOut() ([]byte, error)

GetStdOut - get stdout

type ClientGroupProcMsgResults added in v0.7.130

type ClientGroupProcMsgResults struct {
	Results []*JarvisMsgInfo `json:"results"`
}

ClientGroupProcMsgResults - result for FuncOnSendMsgResult

type Config

type Config struct {
	RootServAddr string
	LstTrustNode []string

	// TimeRequestChild - RequestChild time
	//					- default 30s
	TimeRequestChild int64

	// MaxMsgLength - default 4mb
	MaxMsgLength int32

	Pprof struct {
		BaseURL string
	}

	TaskServ struct {
		BindAddr string
		ServAddr string
	}

	HTTPServ struct {
		BindAddr string
		ServAddr string
	}

	AnkaDB struct {
		DBPath   string
		HTTPServ string
		Engine   string
	}

	Log struct {
		LogPath        string
		LogLevel       string
		LogConsole     bool
		LogSubFileName string
	}

	BaseNodeInfo struct {
		NodeName string
		BindAddr string
		ServAddr string
	}

	AutoUpdate    bool
	UpdateScript  string
	RestartScript string
}

Config - config

func LoadConfig

func LoadConfig(filename string) (*Config, error)

LoadConfig - load config

type Ctrl

type Ctrl interface {
	Run(ctx context.Context, jarvisnode JarvisNode, srcAddr string, msgid int64, ci *pb.CtrlInfo) []*pb.JarvisMsg
}

Ctrl -

type CtrlScriptFile

type CtrlScriptFile struct {
}

CtrlScriptFile -

func (*CtrlScriptFile) Run

func (ctrl *CtrlScriptFile) Run(ctx context.Context, jarvisnode JarvisNode, srcAddr string, msgid int64, ci *pb.CtrlInfo) []*pb.JarvisMsg

Run -

type CtrlScriptFile2 added in v0.6.21

type CtrlScriptFile2 struct {
}

CtrlScriptFile2 -

func (*CtrlScriptFile2) Run added in v0.6.21

func (ctrl *CtrlScriptFile2) Run(ctx context.Context, jarvisnode JarvisNode, srcAddr string, msgid int64, ci *pb.CtrlInfo) []*pb.JarvisMsg

Run -

type CtrlScriptFile3 added in v0.7.130

type CtrlScriptFile3 struct {
}

CtrlScriptFile3 -

func (*CtrlScriptFile3) Run added in v0.7.130

func (ctrl *CtrlScriptFile3) Run(ctx context.Context, jarvisnode JarvisNode,
	srcAddr string, msgid int64, ci *pb.CtrlInfo) []*pb.JarvisMsg

Run -

type FuncGetMsgState added in v0.7.157

type FuncGetMsgState func(addr string, msgid int64) int

FuncGetMsgState - getMsgState

type FuncMsgEvent added in v0.6.1

type FuncMsgEvent func(ctx context.Context, jarvisnode JarvisNode, msg *pb.JarvisMsg) error

FuncMsgEvent - func event

type FuncNodeEvent

type FuncNodeEvent func(ctx context.Context, jarvisnode JarvisNode, node *coredbpb.NodeInfo) error

FuncNodeEvent - func event

type FuncOnFileData added in v0.7.130

type FuncOnFileData func(fd *pb.FileData, isend bool) error

FuncOnFileData - on proc filedata

type FuncOnGroupSendMsgResult added in v0.7.130

type FuncOnGroupSendMsgResult func(ctx context.Context, jarvisnode JarvisNode,
	numsNode int, lstResult []*ClientGroupProcMsgResults) error

FuncOnGroupSendMsgResult - on group sendmsg recv the messages

type FuncOnProcMsgResult added in v0.7.130

type FuncOnProcMsgResult func(ctx context.Context, jarvisnode JarvisNode,
	lstResult []*JarvisMsgInfo) error

FuncOnProcMsgResult - on procmsg recv the message

type FuncOnRangeProcMsgResult added in v0.7.157

type FuncOnRangeProcMsgResult func(prmd *ProcMsgResultData)

FuncOnRangeProcMsgResult - onRangeProcMsgResult

type FuncOnTimer added in v0.7.157

type FuncOnTimer func(ctx context.Context, timer *Timer) bool

FuncOnTimer - on timer

  • If it returns false, the timer will end

type FuncStateEvent added in v0.7.130

type FuncStateEvent func(ctx context.Context, jarvisnode JarvisNode) error

FuncStateEvent - func event

type HTTPServer added in v0.7.178

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

HTTPServer -

type JarvisMsgInfo added in v0.7.130

type JarvisMsgInfo struct {
	JarvisResultType int           `json:"jarvisresulttype"`
	Msg              *pb.JarvisMsg `json:"msg"`
	Err              error         `json:"err"`
}

JarvisMsgInfo - JarvisMsg information

func (*JarvisMsgInfo) IsEnd added in v0.7.157

func (jmi *JarvisMsgInfo) IsEnd() bool

IsEnd - is end msg

func (*JarvisMsgInfo) IsEndOrIGI added in v0.7.157

func (jmi *JarvisMsgInfo) IsEndOrIGI() bool

IsEndOrIGI - is end msg or IGOTIT

func (*JarvisMsgInfo) IsErrorEnd added in v0.7.187

func (jmi *JarvisMsgInfo) IsErrorEnd() bool

IsErrorEnd - is error end msg

type JarvisMsgReplyStream added in v0.7.130

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

JarvisMsgReplyStream - reply JarvisMsg stream

func NewJarvisMsgReplyStream added in v0.7.130

func NewJarvisMsgReplyStream(procMsg pb.JarvisCoreServ_ProcMsgServer) *JarvisMsgReplyStream

NewJarvisMsgReplyStream - new JarvisMsgReplyStream

func (*JarvisMsgReplyStream) ReplyMsg added in v0.7.130

func (stream *JarvisMsgReplyStream) ReplyMsg(jn JarvisNode, sendmsg *pb.JarvisMsg) error

ReplyMsg - reply JarvisMsg

type JarvisMsgTask added in v0.7.166

type JarvisMsgTask struct {
	Normal *NormalMsgTaskInfo
	Stream *StreamMsgTaskInfo
}

JarvisMsgTask - jarvis message task

type JarvisNode

type JarvisNode interface {
	// Start - start jarvis node
	Start(ctx context.Context) (err error)
	// Stop - stop jarvis node
	Stop() (err error)
	// GetCoreDB - get jarvis node coredb
	GetCoreDB() *coredb.CoreDB

	// GetConfig - get config
	GetConfig() *Config

	// BuildStatus - build jarviscorepb.JarvisNodeStatus
	BuildStatus() *pb.JarvisNodeStatus

	// RequestCtrl - send ctrl to jarvisnode with addr
	RequestCtrl(ctx context.Context, addr string, ci *pb.CtrlInfo,
		funcOnResult FuncOnProcMsgResult) error
	// SendFile - send filedata to jarvisnode with addr
	SendFile(ctx context.Context, addr string, fd *pb.FileData,
		funcOnResult FuncOnProcMsgResult) error
	// SendFile2 - send filedata to jarvisnode with addr
	SendFile2(ctx context.Context, addr string, fd *pb.FileData,
		funcOnResult FuncOnProcMsgResult) error
	// RequestFile - request node send filedata to me
	RequestFile(ctx context.Context, addr string, rf *pb.RequestFile,
		funcOnResult FuncOnProcMsgResult) error
	// RequestNodes - request nodes
	RequestNodes(ctx context.Context, isNeedLocalHost bool, funcOnResult FuncOnGroupSendMsgResult) error
	// UpdateNode - update node
	UpdateNode(ctx context.Context, addr string, nodetype string, nodetypever string, isOnlyRestart bool,
		funcOnResult FuncOnProcMsgResult) error
	// UpdateAllNodes - update all nodes
	UpdateAllNodes(ctx context.Context, nodetype string, nodetypever string, isOnlyRestart bool,
		funcOnResult FuncOnGroupSendMsgResult) error
	// ClearLogs - clear logs
	ClearLogs(ctx context.Context, addr string, funcOnResult FuncOnProcMsgResult) error
	// ClearAllLogs - clear logs
	ClearAllLogs(ctx context.Context, funcOnResult FuncOnGroupSendMsgResult) error

	// AddNodeBaseInfo - add nodeinfo
	AddNodeBaseInfo(nbi *pb.NodeBaseInfo) error

	// OnMsg - proc JarvisMsg
	OnMsg(ctx context.Context, task *JarvisMsgTask) error

	// GetMyInfo - get my nodeinfo
	GetMyInfo() *BaseInfo

	// RegNodeEventFunc - reg event handle
	RegNodeEventFunc(event string, eventfunc FuncNodeEvent) error
	// RegMsgEventFunc - reg event handle
	RegMsgEventFunc(event string, eventfunc FuncMsgEvent) error

	// IsConnected - is connected this node
	IsConnected(addr string) bool

	// FindNodeWithName - find node with name
	FindNodeWithName(name string) *coredbpb.NodeInfo
	// FindNode - find node
	FindNode(addr string) *coredbpb.NodeInfo

	// SetNodeTypeInfo - set node type and version
	SetNodeTypeInfo(nodetype string, nodetypeversion string)

	// RegCtrl - register a ctrl
	RegCtrl(ctrltype string, ctrl Ctrl) error

	// PostMsg - like windows postMessage
	PostMsg(normal *NormalMsgTaskInfo, chanEnd chan int)
	// PostStreamMsg - like windows postMessage
	PostStreamMsg(stream *StreamMsgTaskInfo, chanEnd chan int)

	// SendStreamMsg - send stream message to other node
	SendStreamMsg(addr string, msgs []*pb.JarvisMsg, funcOnResult FuncOnProcMsgResult)
	// SendMsg - send a message to other node
	SendMsg(addr string, msg *pb.JarvisMsg, funcOnResult FuncOnProcMsgResult)

	// ConnectNode - connect node
	ConnectNode(node *coredbpb.NodeInfo, funcOnResult FuncOnProcMsgResult) error
	// ConnectNodeWithServAddr - connect node
	ConnectNodeWithServAddr(servaddr string, funcOnResult FuncOnProcMsgResult) error

	// OnClientProcMsg - on Client.ProcMsg
	OnClientProcMsg(addr string, msgid int64, onProcMsgResult FuncOnProcMsgResult) error
	// OnReplyProcMsg - on reply
	OnReplyProcMsg(ctx context.Context, addr string, replymsgid int64, jrt int, msg *pb.JarvisMsg, err error) error
}

JarvisNode -

func NewNode

func NewNode(cfg *Config) (JarvisNode, error)

NewNode -

type NormalMsgTaskInfo added in v0.7.166

type NormalMsgTaskInfo struct {
	Msg         *pb.JarvisMsg
	ReplyStream *JarvisMsgReplyStream
	OnResult    FuncOnProcMsgResult
}

NormalMsgTaskInfo - normal message task info

type ProcMsgResultData added in v0.7.130

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

ProcMsgResultData -

func NewProcMsgResultData added in v0.7.130

func NewProcMsgResultData(addr string, msgid int64, onProcMsgResult FuncOnProcMsgResult) *ProcMsgResultData

NewProcMsgResultData - new ProcMsgResultData

func (*ProcMsgResultData) OnMsgEnd added in v0.7.130

func (pmrd *ProcMsgResultData) OnMsgEnd() bool

OnMsgEnd - on MsgEnd

func (*ProcMsgResultData) OnPorcMsgResult added in v0.7.130

func (pmrd *ProcMsgResultData) OnPorcMsgResult(ctx context.Context, jarvisnode JarvisNode, result *JarvisMsgInfo) error

OnPorcMsgResult - on PorcMsgResult

func (*ProcMsgResultData) OnRecvEnd added in v0.7.130

func (pmrd *ProcMsgResultData) OnRecvEnd() bool

OnRecvEnd - on RecvEnd

type RestartNodeParam added in v0.7.185

type RestartNodeParam struct {
}

RestartNodeParam - the parameter for restart node

type StreamMsgTaskInfo added in v0.7.166

type StreamMsgTaskInfo struct {
	Msgs        []JarvisMsgInfo
	ReplyStream *JarvisMsgReplyStream
	OnResult    FuncOnProcMsgResult
}

StreamMsgTaskInfo - stream message task info

type Timer added in v0.7.157

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

Timer - timer

func NewTimer added in v0.7.157

func NewTimer(timer int, ontimer FuncOnTimer) *Timer

NewTimer - new timer

func StartTimer added in v0.7.157

func StartTimer(ctx context.Context, timer int, ontimer FuncOnTimer) (*Timer, error)

StartTimer - start timer

func (*Timer) Start added in v0.7.157

func (t *Timer) Start(ctx context.Context)

Start - start

type UpdateNodeParam added in v0.7.130

type UpdateNodeParam struct {
	NewVersion string
}

UpdateNodeParam - the parameter for update node

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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