Documentation ¶
Index ¶
- func IsContains(list []string, element string) (exist bool)
- func IsContainsV3(list []string, element string) (exist bool)
- type AliasPlugin
- type CompressionPlugin
- type ConsulRegisterPlugin
- func (plugin *ConsulRegisterPlugin) CheckFail(name string) (err error)
- func (plugin *ConsulRegisterPlugin) CheckPass(name string) (err error)
- func (plugin *ConsulRegisterPlugin) Close()
- func (plugin *ConsulRegisterPlugin) FindServices(name string) []*api.AgentService
- func (plugin *ConsulRegisterPlugin) Name() string
- func (plugin *ConsulRegisterPlugin) Register(name string, rcvr interface{}, metadata ...string) (err error)
- func (plugin *ConsulRegisterPlugin) Start() (err error)
- func (plugin *ConsulRegisterPlugin) Unregister(name string) (err error)
- type EtcdRegisterPlugin
- func (p *EtcdRegisterPlugin) Close()
- func (p *EtcdRegisterPlugin) HandleConnAccept(conn net.Conn) (net.Conn, bool)
- func (p *EtcdRegisterPlugin) Name() string
- func (p *EtcdRegisterPlugin) Register(name string, rcvr interface{}, metadata ...string) (err error)
- func (p *EtcdRegisterPlugin) Start() (err error)
- func (p *EtcdRegisterPlugin) Unregister(name string) (err error)
- type EtcdV3RegisterPlugin
- func (p *EtcdV3RegisterPlugin) Close()
- func (p *EtcdV3RegisterPlugin) HandleConnAccept(conn net.Conn) (net.Conn, bool)
- func (p *EtcdV3RegisterPlugin) Name() string
- func (p *EtcdV3RegisterPlugin) Put(key, value string, opts ...clientv3.OpOption) error
- func (p *EtcdV3RegisterPlugin) Register(name string, rcvr interface{}, metadata ...string) (err error)
- func (p *EtcdV3RegisterPlugin) Start() (err error)
- func (p *EtcdV3RegisterPlugin) Unregister(name string) (err error)
- type LogRegisterPlugin
- type MetricsPlugin
- func (p *MetricsPlugin) Exp()
- func (p *MetricsPlugin) Graphite(freq time.Duration, prefix string, addr *net.TCPAddr)
- func (p *MetricsPlugin) HandleConnAccept(conn net.Conn) (net.Conn, bool)
- func (p *MetricsPlugin) InfluxDB(freq time.Duration, url, database, username, password string)
- func (p *MetricsPlugin) Log(freq time.Duration, l metrics.Logger)
- func (p *MetricsPlugin) Name() string
- func (p *MetricsPlugin) PostReadRequestHeader(ctx context.Context, r *core.Request) error
- func (p *MetricsPlugin) PostWriteResponse(ctx context.Context, r *core.Response, body interface{}) error
- func (p *MetricsPlugin) PreReadRequestHeader(ctx context.Context, r *core.Request) error
- func (p *MetricsPlugin) Register(name string, rcvr interface{}, metadata ...string) error
- func (p *MetricsPlugin) Syslog(freq time.Duration, w *syslog.Writer)
- type RateLimitingPlugin
- type ZooKeeperRegisterPlugin
- func (plugin *ZooKeeperRegisterPlugin) Close()
- func (plugin *ZooKeeperRegisterPlugin) HandleConnAccept(conn net.Conn) (net.Conn, bool)
- func (plugin *ZooKeeperRegisterPlugin) Name() string
- func (plugin *ZooKeeperRegisterPlugin) Register(name string, rcvr interface{}, metadata ...string) (err error)
- func (plugin *ZooKeeperRegisterPlugin) Start() (err error)
- func (plugin *ZooKeeperRegisterPlugin) StartWithZKConn(conn *zk.Conn) (err error)
- func (plugin *ZooKeeperRegisterPlugin) Unregister(name string) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsContains ¶
func IsContainsV3 ¶
Types ¶
type AliasPlugin ¶
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) PostReadRequestHeader ¶
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 ¶
HandleConnAccept can create a conn that support compression. Used by servers.
func (*CompressionPlugin) HandleConnected ¶
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 UpdateInterval time.Duration // contains filtered or unexported fields }
ConsulRegisterPlugin a register plugin which can register services into consul for cluster.
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 ExtraTime time.Duration KeysAPI client.KeysAPI // contains filtered or unexported fields }
EtcdRegisterPlugin a register plugin which can register services into etcd for cluster
func (*EtcdRegisterPlugin) HandleConnAccept ¶
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 UpdateIntervalInSec 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 ¶
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.
type MetricsPlugin ¶
type MetricsPlugin struct { Registry metrics.Registry Prefix string // 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 ¶
Graphite reports metrics into graphite.
addr, _ := net.ResolveTCPAddr("tcp", "127.0.0.1:2003") p.Graphite(10e9, "metrics", addr)
func (*MetricsPlugin) HandleConnAccept ¶
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) PostReadRequestHeader ¶
PostReadRequestHeader counts read
func (*MetricsPlugin) PostWriteResponse ¶
func (p *MetricsPlugin) PostWriteResponse(ctx context.Context, r *core.Response, body interface{}) error
PostWriteResponse count write
func (*MetricsPlugin) PreReadRequestHeader ¶
PreReadRequestHeader marks start time of calling service
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 ¶
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 // contains filtered or unexported fields }
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 ¶
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) StartWithZKConn ¶
func (plugin *ZooKeeperRegisterPlugin) StartWithZKConn(conn *zk.Conn) (err error)
StartWithZKConn starts with a shared zk connection.
func (*ZooKeeperRegisterPlugin) Unregister ¶
func (plugin *ZooKeeperRegisterPlugin) Unregister(name string) (err error)
Unregister a service from zookeeper but this service still exists in this node.