module

package
v0.0.0-...-84310d3 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LifecycleManager

type LifecycleManager struct {
	sync.RWMutex

	// Modules are looked up from these dirs. Each module is a
	// directory.  Modules use the / separator. Module ookup dirs use
	// the hos specific path separator
	ModuleLookupDirs []string

	// RunModuleScript should run module.w in the given dir. Should
	// return error only if execution fails. First is true if this is the
	// first loading of the module in this run
	RunModuleScript func(first bool, dir string) error

	// LocalModuleFunc is called to see if the module is local. If it
	// is, then this should handle the call to the module, and should
	// return response,true,err. If the module is not local, it should
	// return response,false,nil
	LocalModuleFunc func(session, module, funcName string, data []byte) (server.Response, bool, error)
	// contains filtered or unexported fields
}

LifecycleManager deals with managing the external module lifecycle. Create a LifecycleManager for the module, and then start the module. The lifecycle manager waits for the module to connect back to the server.

func NewLifecycleManager

func NewLifecycleManager() *LifecycleManager

NewLifecycleManager returns a new lifecycle manager to keep track of modules connected to the server

func (*LifecycleManager) Close

func (mgr *LifecycleManager) Close()

Close and shutdown all modules

func (*LifecycleManager) Connect

func (mgr *LifecycleManager) Connect(stream pb.Lifecycle_ConnectServer) error

Connect is called by the client runtime once the module loads. When connected, this will initialize the module information in the server, and ping the module. A failed ping will remove the module from the module info map. The lifecycle manager must be locked during this call

func (*LifecycleManager) ExecModule

func (mgr *LifecycleManager) ExecModule(name string, args ...string) error

ExecModule executes the module script and listens to its output

func (*LifecycleManager) GetArgs

func (mgr *LifecycleManager) GetArgs(ctx context.Context, req *pb.Session) (*pb.Args, error)

GetArgs returns the args to the program

func (*LifecycleManager) GetCfg

func (mgr *LifecycleManager) GetCfg(ctx context.Context, req *pb.CfgRequest) (*pb.CfgResponse, error)

GetCfg returns a configuration item by name

func (*LifecycleManager) LoadModule

LoadModule loads a module and returns it GRPC port

func (*LifecycleManager) Log

func (mgr *LifecycleManager) Log(ctx context.Context, req *pb.LogRequest) (*pb.Empty, error)

Log a message

func (*LifecycleManager) ModuleCall

func (mgr *LifecycleManager) ModuleCall(ctx context.Context, req *pb.ModuleWorkRequest) (*pb.Response, error)

ModuleCall is called by a module to call another module

func (*LifecycleManager) Print

func (mgr *LifecycleManager) Print(ctx context.Context, req *pb.LogRequest) (*pb.Empty, error)

Print a message

func (*LifecycleManager) SearchModuleDir

func (mgr *LifecycleManager) SearchModuleDir(module string) (string, bool)

SearchModuleDir finds a module directory from the given name. It looks up the search directories to see if such module is under any one of them

func (*LifecycleManager) SendRequest

func (mgr *LifecycleManager) SendRequest(session, module, funcName string, data []byte) (server.Response, error)

SendRequest calls a function in a module with the data, and returns the response

Jump to

Keyboard shortcuts

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