serverplugin

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2018 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFunctionName

func GetFunctionName(i interface{}) string

Types

type AliasPlugin

type AliasPlugin struct {
	Aliases          map[string]*aliasPair
	ReseverseAliases map[string]*aliasPair
}

AliasPlugin can be used to set aliases for services

func NewAliasPlugin

func NewAliasPlugin() *AliasPlugin

NewAliasPlugin creates a new NewAliasPlugin

func (*AliasPlugin) Alias

func (p *AliasPlugin) Alias(aliasServicePath, aliasServiceMethod string, servicePath, serviceMethod string)

Alias sets a alias for the serviceMethod. For example Alias("anewpath&method", "Arith.mul")

func (*AliasPlugin) PostReadRequest

func (p *AliasPlugin) PostReadRequest(ctx context.Context, r *protocol.Message, e error) error

PostReadRequest converts the alias of this service.

func (*AliasPlugin) PreWriteResponse

func (p *AliasPlugin) PreWriteResponse(ctx context.Context, r *protocol.Message, res *protocol.Message) error

PreWriteResponse restore servicePath and serviceMethod.

type ConsulRegisterPlugin

type ConsulRegisterPlugin struct {
	// service address, for example, tcp@127.0.0.1:8972, quic@127.0.0.1:1234
	ServiceAddress string
	// consul addresses
	ConsulServers []string
	// base path for rpcx server, for example com/example/rpcx
	BasePath string
	Metrics  metrics.Registry
	// Registered services
	Services []string

	UpdateInterval time.Duration

	Options *store.Config
	// contains filtered or unexported fields
}

ConsulRegisterPlugin implements consul registry.

func (*ConsulRegisterPlugin) HandleConnAccept

func (p *ConsulRegisterPlugin) HandleConnAccept(conn net.Conn) (net.Conn, bool)

HandleConnAccept handles connections from clients

func (*ConsulRegisterPlugin) Register

func (p *ConsulRegisterPlugin) Register(name string, rcvr interface{}, metadata string) (err error)

Register handles registering event. this service is registered at BASE/serviceName/thisIpAddress node

func (*ConsulRegisterPlugin) Start

func (p *ConsulRegisterPlugin) Start() error

Start starts to connect consul cluster

func (*ConsulRegisterPlugin) Stop

func (p *ConsulRegisterPlugin) Stop() error

Stop unregister all services.

func (*ConsulRegisterPlugin) Unregister

func (p *ConsulRegisterPlugin) Unregister(name string) (err error)

type EtcdRegisterPlugin

type EtcdRegisterPlugin struct {
	// service address, for example, tcp@127.0.0.1:8972, quic@127.0.0.1:1234
	ServiceAddress string
	// etcd addresses
	EtcdServers []string
	// base path for rpcx server, for example com/example/rpcx
	BasePath string
	Metrics  metrics.Registry
	// Registered services
	Services []string

	UpdateInterval time.Duration

	Options *store.Config
	// contains filtered or unexported fields
}

EtcdRegisterPlugin implements etcd registry.

func (*EtcdRegisterPlugin) HandleConnAccept

func (p *EtcdRegisterPlugin) HandleConnAccept(conn net.Conn) (net.Conn, bool)

HandleConnAccept handles connections from clients

func (*EtcdRegisterPlugin) Register

func (p *EtcdRegisterPlugin) Register(name string, rcvr interface{}, metadata string) (err error)

Register handles registering event. this service is registered at BASE/serviceName/thisIpAddress node

func (*EtcdRegisterPlugin) Start

func (p *EtcdRegisterPlugin) Start() error

Start starts to connect etcd cluster

func (*EtcdRegisterPlugin) Stop

func (p *EtcdRegisterPlugin) Stop() error

Stop unregister all services.

func (*EtcdRegisterPlugin) Unregister

func (p *EtcdRegisterPlugin) Unregister(name string) (err error)

type MDNSRegisterPlugin

type MDNSRegisterPlugin struct {
	// service address, for example, tcp@127.0.0.1:8972, quic@127.0.0.1:1234
	ServiceAddress string

	Metrics metrics.Registry
	// Registered services
	Services       []*serviceMeta
	UpdateInterval time.Duration
	// contains filtered or unexported fields
}

MDNSRegisterPlugin implements mdns/dns-sd registry.

func NewMDNSRegisterPlugin

func NewMDNSRegisterPlugin(serviceAddress string, port int, m metrics.Registry, updateInterval time.Duration, domain string) *MDNSRegisterPlugin

NewMDNSRegisterPlugin return a new MDNSRegisterPlugin. If domain is empty, use "local." in default.

func (*MDNSRegisterPlugin) HandleConnAccept

func (p *MDNSRegisterPlugin) HandleConnAccept(conn net.Conn) (net.Conn, bool)

HandleConnAccept handles connections from clients

func (*MDNSRegisterPlugin) Register

func (p *MDNSRegisterPlugin) Register(name string, rcvr interface{}, metadata string) (err error)

Register handles registering event. this service is registered at BASE/serviceName/thisIpAddress node

func (*MDNSRegisterPlugin) Start

func (p *MDNSRegisterPlugin) Start() error

Start starts to connect etcd cluster

func (*MDNSRegisterPlugin) Stop

func (p *MDNSRegisterPlugin) Stop() error

Stop unregister all services.

func (*MDNSRegisterPlugin) Unregister

func (p *MDNSRegisterPlugin) Unregister(name string) (err error)

type MetricsPlugin

type MetricsPlugin struct {
	Registry metrics.Registry
	Prefix   string
}

MetricsPlugin collects metrics of a rpc server. You can report metrics to log, syslog, Graphite, InfluxDB or others to display them in Dashboard such as grafana, Graphite.

func NewMetricsPlugin

func NewMetricsPlugin(registry metrics.Registry) *MetricsPlugin

NewMetricsPlugin creates a new MetricsPlugirn

func (*MetricsPlugin) Exp

func (p *MetricsPlugin) Exp()

Exp uses the same mechanism as the official expvar but exposed under /debug/metrics, which shows a json representation of all your usual expvars as well as all your go-metrics.

func (*MetricsPlugin) Graphite

func (p *MetricsPlugin) Graphite(freq time.Duration, prefix string, addr *net.TCPAddr)

Graphite reports metrics into graphite.

	addr, _ := net.ResolveTCPAddr("tcp", "127.0.0.1:2003")
 p.Graphite(10e9, "metrics", addr)

func (*MetricsPlugin) HandleConnAccept

func (p *MetricsPlugin) HandleConnAccept(conn net.Conn) (net.Conn, bool)

HandleConnAccept handles connections from clients

func (*MetricsPlugin) InfluxDB

func (p *MetricsPlugin) InfluxDB(freq time.Duration, url, database, username, password string)

InfluxDB reports metrics into influxdb.

p.InfluxDB(10e9, "http://127.0.0.1:8086","metrics", "test","test"})

func (*MetricsPlugin) InfluxDBWithTags

func (p *MetricsPlugin) InfluxDBWithTags(freq time.Duration, url, database, username, password string, tags map[string]string)

InfluxDBWithTags reports metrics into influxdb with tags. you can set node info into tags.

p.InfluxDBWithTags(10e9, "http://127.0.0.1:8086","metrics", "test","test", map[string]string{"host":"127.0.0.1"})

func (*MetricsPlugin) Log

func (p *MetricsPlugin) Log(freq time.Duration, l metrics.Logger)

Log reports metrics into logs.

p.Log( 5 * time.Second, log.New(os.Stderr, "metrics: ", log.Lmicroseconds))

func (*MetricsPlugin) PostReadRequest

func (p *MetricsPlugin) PostReadRequest(ctx context.Context, r *protocol.Message, e error) error

PostReadRequest counts read

func (*MetricsPlugin) PostWriteResponse

func (p *MetricsPlugin) PostWriteResponse(ctx context.Context, req *protocol.Message, res *protocol.Message, e error) error

PostWriteResponse count write

func (*MetricsPlugin) PreReadRequest

func (p *MetricsPlugin) PreReadRequest(ctx context.Context) error

PreReadRequest marks start time of calling service

func (*MetricsPlugin) Register

func (p *MetricsPlugin) Register(name string, rcvr interface{}, metadata string) error

Register handles registering event.

type RateLimitingPlugin

type RateLimitingPlugin struct {
	FillInterval time.Duration
	Capacity     int64
	// contains filtered or unexported fields
}

RateLimitingPlugin can limit connecting per unit time

func NewRateLimitingPlugin

func NewRateLimitingPlugin(fillInterval time.Duration, capacity int64) *RateLimitingPlugin

NewRateLimitingPlugin creates a new RateLimitingPlugin

func (*RateLimitingPlugin) HandleConnAccept

func (plugin *RateLimitingPlugin) HandleConnAccept(conn net.Conn) (net.Conn, bool)

HandleConnAccept can limit connecting rate

type TracePlugin

type TracePlugin struct {
}

func (*TracePlugin) PostConnAccept

func (p *TracePlugin) PostConnAccept(conn net.Conn) (net.Conn, bool)

func (*TracePlugin) PostReadRequest

func (p *TracePlugin) PostReadRequest(ctx context.Context, r *protocol.Message, e error) error

func (*TracePlugin) PostWriteResponse

func (p *TracePlugin) PostWriteResponse(ctx context.Context, req *protocol.Message, res *protocol.Message, err error) error

func (*TracePlugin) Register

func (p *TracePlugin) Register(name string, rcvr interface{}, metadata string) error

func (*TracePlugin) RegisterFunction

func (p *TracePlugin) RegisterFunction(name string, fn interface{}, metadata string) error

type ZooKeeperRegisterPlugin

type ZooKeeperRegisterPlugin struct {
	// service address, for example, tcp@127.0.0.1:8972, quic@127.0.0.1:1234
	ServiceAddress string
	// zookeeper addresses
	ZooKeeperServers []string
	// base path for rpcx server, for example com/example/rpcx
	BasePath string
	Metrics  metrics.Registry
	// Registered services
	Services []string

	UpdateInterval time.Duration

	Options *store.Config
	// contains filtered or unexported fields
}

ZooKeeperRegisterPlugin implements zookeeper registry.

func (*ZooKeeperRegisterPlugin) HandleConnAccept

func (p *ZooKeeperRegisterPlugin) HandleConnAccept(conn net.Conn) (net.Conn, bool)

HandleConnAccept handles connections from clients

func (*ZooKeeperRegisterPlugin) Register

func (p *ZooKeeperRegisterPlugin) Register(name string, rcvr interface{}, metadata string) (err error)

Register handles registering event. this service is registered at BASE/serviceName/thisIpAddress node

func (*ZooKeeperRegisterPlugin) Start

func (p *ZooKeeperRegisterPlugin) Start() error

Start starts to connect zookeeper cluster

func (*ZooKeeperRegisterPlugin) Stop

func (p *ZooKeeperRegisterPlugin) Stop() error

Stop unregister all services.

func (*ZooKeeperRegisterPlugin) Unregister

func (p *ZooKeeperRegisterPlugin) Unregister(name string) (err error)

Jump to

Keyboard shortcuts

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