plugin

package module
v0.0.0-...-6edd512 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: BSD-3-Clause Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DummyOnInit

func DummyOnInit[T any](plugin *Plugin[T], conf map[string]any) map[string]any

func GetManifest

func GetManifest[T any](plugin *Plugin[T], request map[string]any) (map[string]any, error)

GetManifest - is a method to generate the manfest object needed by Core Damon to register the plugin. https://lightning.readthedocs.io/PLUGINS.html

func InitCall

func InitCall[T any](plugin *Plugin[T], request map[string]any) (map[string]any, error)

InitCall - method is called by Core Damon after the command line options has been parsed and the plugin has been loaded.

Types

type Id

type Id = jsonrpcv2.Id

type Map

type Map = map[string]any

type Plugin

type Plugin[T any] struct {
	State         T
	RpcMethods    map[string]*rpcMethod[T]
	Notifications map[string]*rpcNotification[T]
	Hooks         map[string]*rpcHook[T]
	Subscriptions map[string]*rpcNotification[T]
	Options       map[string]*rpcOption
	FeatureBits   map[string]any

	Configuration map[string]any
	// contains filtered or unexported fields
}

Plugin is the base plugin structure. Used to create and manage the state of a plugin.

func New

func New[T any](state T, dynamic bool, onInit func(plugin *Plugin[T], config map[string]any) map[string]any) *Plugin[T]

FIXME: try to pass the pointer of the state to avoid the double copy here!

func (*Plugin[T]) Decode

func (self *Plugin[T]) Decode(payload map[string]any, destination any) error

func (*Plugin[T]) Encode

func (self *Plugin[T]) Encode(obj any) (map[string]any, error)

func (*Plugin[T]) GetConf

func (instance *Plugin[T]) GetConf(key string) (any, bool)

Method to get a plugin configuration.

func (*Plugin[T]) GetEncoder

func (self *Plugin[T]) GetEncoder() encoder.JSONEncoder

func (*Plugin[T]) GetOpt

func (instance *Plugin[T]) GetOpt(key string) (any, bool)

Method to get a plugin option.

func (*Plugin[T]) GetState

func (self *Plugin[T]) GetState() T

func (*Plugin[T]) Log

func (instance *Plugin[T]) Log(level string, message string)

func (*Plugin[T]) RegisterHook

func (instance *Plugin[T]) RegisterHook(name string, before []string, after []string, callback func(plugin *Plugin[T], request Map) (Map, error))

Method to add a new rpc hook to the plugin.

func (*Plugin[T]) RegisterNotification

func (instance *Plugin[T]) RegisterNotification(name string, callback func(plugin *Plugin[T], request Map))

Method to add a new rpc notification to the plugin.

func (*Plugin[T]) RegisterOption

func (instance *Plugin[T]) RegisterOption(name string, typ string, def string, description string, deprecated bool)

Method to add a new plugin option.

func (*Plugin[T]) RegisterRPCMethod

func (instance *Plugin[T]) RegisterRPCMethod(name string, usage string, description string, callback func(plugin *Plugin[T], request Map) (Map, error))

Method to add a new rpc method to the plugin.

func (*Plugin[T]) SetEncoder

func (self *Plugin[T]) SetEncoder(encoder encoder.JSONEncoder)

func (*Plugin[T]) SetTracer

func (self *Plugin[T]) SetTracer(tracer tracer.Tracer)

func (*Plugin[T]) Start

func (self *Plugin[T]) Start()

type RPCCommand

type RPCCommand[T any] interface {
	Call(*Plugin[T], map[string]any) (map[string]any, error)
}

RPCCommand FIXME: override the command pattern with the generic type alias when implemented

type RPCEvent

type RPCEvent[T any] interface {
	Call(*Plugin[T], map[string]any)
}

type Request

type Request = jsonrpcv2.Request

type Response

type Response = jsonrpcv2.Response[Map]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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