rpc

package module
v4.4.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 12 Imported by: 3

README

Documentation

Index

Constants

View Source
const PluginName = "rpc"

PluginName contains default plugin name.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

func (*API) Config

func (a *API) Config(_ *bool, out *[]byte) error

func (*API) Version

func (a *API) Version(_ *bool, out *string) error

type Config

type Config struct {
	// Listen address string
	Listen string `mapstructure:"listen"`
}

Config defines RPC service config.

func (*Config) Dialer

func (c *Config) Dialer() (net.Conn, error)

Dialer creates rpc socket Dialer.

func (*Config) InitDefaults

func (c *Config) InitDefaults()

InitDefaults allows to init blank config with pre-defined set of default values.

func (*Config) Listener

func (c *Config) Listener() (net.Listener, error)

Listener creates new rpc socket Listener.

func (*Config) Valid

func (c *Config) Valid() error

Valid returns nil if config is valid.

type Configurer

type Configurer interface {
	// RRVersion returns current RR version
	RRVersion() string
	// Unmarshal returns the whole configuration
	Unmarshal(out any) error
	// UnmarshalKey takes a single key and unmarshal it into a Struct.
	UnmarshalKey(name string, out any) error
	// Has checks if config section exists.
	Has(name string) bool
}

type Logger

type Logger interface {
	NamedLogger(name string) *zap.Logger
}

type Plugin

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

Plugin is RPC service.

func (*Plugin) Collects

func (s *Plugin) Collects() []*dep.In

Collects all plugins which implement Name + RPCer interfaces

func (*Plugin) Init

func (s *Plugin) Init(cfg Configurer, log Logger) error

Init rpc service. Must return true if service is enabled.

func (*Plugin) Name

func (s *Plugin) Name() string

Name contains service name.

func (*Plugin) Register

func (s *Plugin) Register(name string, svc any) error

Register publishes in the server the set of methods of the receiver value that satisfy the following conditions:

  • exported method of exported type
  • two arguments, both of exported type
  • the second argument is a pointer
  • one return value, of type error

It returns an error if the receiver is not an exported type or has no suitable methods. It also logs the error using package log.

func (*Plugin) Serve

func (s *Plugin) Serve() chan error

Serve serves the service.

func (*Plugin) Stop

func (s *Plugin) Stop(context.Context) error

Stop stops the service.

func (*Plugin) Weight added in v4.1.0

func (s *Plugin) Weight() uint

type RPCer

type RPCer interface {
	// RPC Provides methods for the given service.
	RPC() any
	// Name of the plugin
	Name() string
}

RPCer declares the ability to create set of public RPC methods.

Jump to

Keyboard shortcuts

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