plugin

package
v0.0.0-...-46193ff Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2017 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsContains

func IsContains(list []string, element string) (exist bool)

func IsContainsV3

func IsContainsV3(list []string, element string) (exist bool)

Types

type AliasPlugin

type AliasPlugin struct {
	Aliases map[string]string
}

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(alias string, serviceMethod string)

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

func (*AliasPlugin) Name

func (p *AliasPlugin) Name() string

Name return name of this plugin.

func (*AliasPlugin) PostReadRequestHeader

func (p *AliasPlugin) PostReadRequestHeader(r *rpc.Request) error

PostReadRequestHeader converts the alias of this service. This plugin must be added after other IPostReadRequestHeaderPlugins such AuthorizationServerPlugin, Because it converts the service name in requests.

type CompressionPlugin

type CompressionPlugin struct {
	CompressType rpcx.CompressType
}

CompressionPlugin can compress responses and decompress requests

func NewCompressionPlugin

func NewCompressionPlugin(compressType rpcx.CompressType) *CompressionPlugin

NewCompressionPlugin creates a new CompressionPlugin

func (*CompressionPlugin) HandleConnAccept

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

HandleConnAccept can create a conn that support compression. Used by servers.

func (*CompressionPlugin) HandleConnected

func (p *CompressionPlugin) HandleConnected(conn net.Conn) (net.Conn, bool)

HandleConnected can create a conn that support compression. Used by servers.

func (*CompressionPlugin) Name

func (p *CompressionPlugin) Name() string

Name return name of this plugin.

type ConsulRegisterPlugin

type ConsulRegisterPlugin struct {
	ServiceAddress string
	ConsulAddress  string

	Services []string
	// contains filtered or unexported fields
}

ConsulRegisterPlugin a register plugin which can register services into consul for cluster This registry is experimental and has not been test.

func (*ConsulRegisterPlugin) CheckFail

func (plugin *ConsulRegisterPlugin) CheckFail(name string) (err error)

CheckFail sets check fail

func (*ConsulRegisterPlugin) CheckPass

func (plugin *ConsulRegisterPlugin) CheckPass(name string) (err error)

CheckPass sets check pass

func (*ConsulRegisterPlugin) Close

func (plugin *ConsulRegisterPlugin) Close()

Close closes this plugin

func (*ConsulRegisterPlugin) FindServices

func (plugin *ConsulRegisterPlugin) FindServices(name string) []*api.AgentService

FindServices gets a service list by name

func (*ConsulRegisterPlugin) Name

func (plugin *ConsulRegisterPlugin) Name() string

Name return name of this plugin.

func (*ConsulRegisterPlugin) Register

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

Register handles registering event.

func (*ConsulRegisterPlugin) Start

func (plugin *ConsulRegisterPlugin) Start() (err error)

Start starts to connect etcd cluster

func (*ConsulRegisterPlugin) Unregister

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

Unregister a service from consul but this service still exists in this node.

type EtcdRegisterPlugin

type EtcdRegisterPlugin struct {
	ServiceAddress string
	EtcdServers    []string
	BasePath       string
	Metrics        metrics.Registry
	Services       []string
	UpdateInterval time.Duration
	KeysAPI        client.KeysAPI
	// contains filtered or unexported fields
}

EtcdRegisterPlugin a register plugin which can register services into etcd for cluster

func (*EtcdRegisterPlugin) Close

func (p *EtcdRegisterPlugin) Close()

Close closes this plugin

func (*EtcdRegisterPlugin) HandleConnAccept

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

HandleConnAccept handles connections from clients

func (*EtcdRegisterPlugin) Name

func (p *EtcdRegisterPlugin) Name() string

Name return name of this p.

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() (err error)

Start starts to connect etcd cluster

func (*EtcdRegisterPlugin) Unregister

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

Unregister a service from etcd but this service still exists in this node.

type EtcdV3RegisterPlugin

type EtcdV3RegisterPlugin struct {
	ServiceAddress    string
	EtcdServers       []string
	BasePath          string
	Metrics           metrics.Registry
	Services          []string
	UpdateInterval    time.Duration
	UpdateIntervalNum int64
	KeysAPI           *clientv3.Client

	DialTimeout time.Duration
	Username    string
	Password    string
	// contains filtered or unexported fields
}

EtcdV3RegisterPlugin a register plugin which can register services into etcd for cluster

func (*EtcdV3RegisterPlugin) Close

func (p *EtcdV3RegisterPlugin) Close()

Close closes this plugin

func (*EtcdV3RegisterPlugin) HandleConnAccept

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

HandleConnAccept handles connections from clients

func (*EtcdV3RegisterPlugin) Name

func (p *EtcdV3RegisterPlugin) Name() string

Name returns name of this plugin.

func (*EtcdV3RegisterPlugin) Put

func (p *EtcdV3RegisterPlugin) Put(key, value string, opts ...clientv3.OpOption) error

Put KV by V3 API

func (*EtcdV3RegisterPlugin) Register

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

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

func (*EtcdV3RegisterPlugin) Start

func (p *EtcdV3RegisterPlugin) Start() (err error)

Start starts to connect etcd v3 cluster

func (*EtcdV3RegisterPlugin) Unregister

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

Unregister a service from etcd but this service still exists in this node.

type LogRegisterPlugin

type LogRegisterPlugin struct {
	Log func(log string)
}

LogRegisterPlugin is a register plugin which can log registered services in logs

func (*LogRegisterPlugin) Name

func (plugin *LogRegisterPlugin) Name() string

Name return name of this plugin.

func (*LogRegisterPlugin) Register

func (plugin *LogRegisterPlugin) Register(name string, rcvr interface{}, metadata ...string) error

Register handles registering event.

type MetricsPlugin

type MetricsPlugin struct {
	Registry metrics.Registry
	// contains filtered or unexported fields
}

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() *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, "127.0.0.1:8086","metrics", "test","test"})

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) Name

func (p *MetricsPlugin) Name() string

Name return name of this plugin.

func (*MetricsPlugin) PostReadRequestHeader

func (p *MetricsPlugin) PostReadRequestHeader(r *rpc.Request) error

PostReadRequestHeader counts read

func (*MetricsPlugin) PostWriteResponse

func (p *MetricsPlugin) PostWriteResponse(r *rpc.Response, body interface{}) error

PostWriteResponse count write

func (*MetricsPlugin) PreReadRequestHeader

func (p *MetricsPlugin) PreReadRequestHeader(r *rpc.Request) error

PreReadRequestHeader marks start time of calling service

func (*MetricsPlugin) Register

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

Register handles registering event.

func (*MetricsPlugin) Syslog

func (p *MetricsPlugin) Syslog(freq time.Duration, w *syslog.Writer)

Syslog reports metrics into syslog.

w, _ := syslog.Dial("unixgram", "/dev/log", syslog.LOG_INFO, "metrics")
p.Syslog(60e9, w)

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

func (*RateLimitingPlugin) Name

func (plugin *RateLimitingPlugin) Name() string

Name return name of this plugin.

type ZooKeeperRegisterPlugin

type ZooKeeperRegisterPlugin struct {
	ServiceAddress   string
	ZooKeeperServers []string
	BasePath         string
	Conn             *zk.Conn
	Metrics          metrics.Registry
	Services         []string
	UpdateInterval   time.Duration
}

ZooKeeperRegisterPlugin a register plugin which can register services into zookeeper for cluster

func (*ZooKeeperRegisterPlugin) Close

func (plugin *ZooKeeperRegisterPlugin) Close()

Close closes zookeeper connection.

func (*ZooKeeperRegisterPlugin) HandleConnAccept

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

HandleConnAccept handles connections from clients

func (*ZooKeeperRegisterPlugin) Name

func (plugin *ZooKeeperRegisterPlugin) Name() string

Name return name of this plugin.

func (*ZooKeeperRegisterPlugin) Register

func (plugin *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 (plugin *ZooKeeperRegisterPlugin) Start() (err error)

Start starts to connect zookeeper cluster

func (*ZooKeeperRegisterPlugin) Unregister

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

Unregister a service from zookeeper but this service still exists in this node.

Jump to

Keyboard shortcuts

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