Documentation
¶
Index ¶
- Variables
- func GetFunctionName(i interface{}) string
- func InfluxDB(r metrics.Registry, d time.Duration, url, database, username, password string)
- func InfluxDBWithTags(r metrics.Registry, d time.Duration, url, database, username, password string, ...)
- func RegisterFileTransfer(s *server.Server, fileTransfer *FileTransfer)
- type AliasPlugin
- func (p *AliasPlugin) Alias(aliasServicePath, aliasServiceMethod string, servicePath, serviceMethod string)
- func (p *AliasPlugin) PostReadRequest(ctx context.Context, r *protocol.Message, e error) error
- func (p *AliasPlugin) PreWriteResponse(ctx context.Context, r *protocol.Message, res *protocol.Message) error
- type DownloadFileArgs
- type DownloadFileHandler
- type FileTransfer
- type FileTransferArgs
- type FileTransferHandler
- type FileTransferReply
- type FileTransferService
- type MDNSRegisterPlugin
- func (p *MDNSRegisterPlugin) HandleConnAccept(conn net.Conn) (net.Conn, bool)
- func (p *MDNSRegisterPlugin) Register(name string, rcvr interface{}, metadata string) (err error)
- func (p *MDNSRegisterPlugin) Start() error
- func (p *MDNSRegisterPlugin) Stop() error
- func (p *MDNSRegisterPlugin) Unregister(name string) (err error)
- 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) InfluxDBWithTags(freq time.Duration, url, database, username, password string, ...)
- func (p *MetricsPlugin) Log(freq time.Duration, l metrics.Logger)
- func (p *MetricsPlugin) PostReadRequest(ctx context.Context, r *protocol.Message, e error) error
- func (p *MetricsPlugin) PostWriteResponse(ctx context.Context, req *protocol.Message, res *protocol.Message, e error) error
- func (p *MetricsPlugin) PreReadRequest(ctx context.Context) error
- func (p *MetricsPlugin) Register(name string, rcvr interface{}, metadata string) error
- type OpenCensusPlugin
- func (p OpenCensusPlugin) PostConnAccept(conn net.Conn) (net.Conn, bool)
- func (p OpenCensusPlugin) PostWriteResponse(ctx context.Context, req *protocol.Message, res *protocol.Message, err error) error
- func (p OpenCensusPlugin) PreHandleRequest(ctx context.Context, r *protocol.Message) error
- func (p OpenCensusPlugin) Register(name string, rcvr interface{}, metadata string) error
- func (p OpenCensusPlugin) RegisterFunction(name string, fn interface{}, metadata string) error
- type OpenTracingPlugin
- func (p OpenTracingPlugin) PostConnAccept(conn net.Conn) (net.Conn, bool)
- func (p OpenTracingPlugin) PostWriteResponse(ctx context.Context, req *protocol.Message, res *protocol.Message, err error) error
- func (p OpenTracingPlugin) PreHandleRequest(ctx context.Context, r *protocol.Message) error
- func (p OpenTracingPlugin) Register(name string, rcvr interface{}, metadata string) error
- func (p OpenTracingPlugin) RegisterFunction(name string, fn interface{}, metadata string) error
- type RateLimitingPlugin
- type TracePlugin
- func (p *TracePlugin) PostConnAccept(conn net.Conn) (net.Conn, bool)
- func (p *TracePlugin) PostReadRequest(ctx context.Context, r *protocol.Message, e error) error
- func (p *TracePlugin) PostWriteResponse(ctx context.Context, req *protocol.Message, res *protocol.Message, err error) error
- func (p *TracePlugin) Register(name string, rcvr interface{}, metadata string) error
- func (p *TracePlugin) RegisterFunction(name string, fn interface{}, metadata string) error
Constants ¶
This section is empty.
Variables ¶
var (
SendFileServiceName = "_filetransfer"
)
Functions ¶
func GetFunctionName ¶
func GetFunctionName(i interface{}) string
func InfluxDB ¶ added in v1.4.1
InfluxDB starts a InfluxDB reporter which will post the metrics from the given registry at each d interval.
func InfluxDBWithTags ¶ added in v1.4.1
func InfluxDBWithTags(r metrics.Registry, d time.Duration, url, database, username, password string, tags map[string]string)
InfluxDBWithTags starts a InfluxDB reporter which will post the metrics from the given registry at each d interval with the specified tags
func RegisterFileTransfer ¶ added in v1.4.1
func RegisterFileTransfer(s *server.Server, fileTransfer *FileTransfer)
RegisterFileTransfer register filetransfer service into the server.
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(aliasServicePath, aliasServiceMethod string, servicePath, serviceMethod string)
Alias sets a alias for the serviceMethod. For example Alias("anewpath&method", "Arith.mul")
func (*AliasPlugin) PostReadRequest ¶
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 DownloadFileArgs ¶ added in v1.4.1
type DownloadFileArgs struct {
FileName string `json:"file_name,omitempty"`
}
DownloadFileArgs args from clients.
type DownloadFileHandler ¶ added in v1.4.1
type DownloadFileHandler func(conn net.Conn, args *DownloadFileArgs)
DownloadFileHandler handles downloading file. Must close the connection after it finished.
type FileTransfer ¶ added in v1.4.1
type FileTransfer struct {
Addr string
// contains filtered or unexported fields
}
FileTransfer support transfer files from clients. It registers a file transfer service and listens a on the given port. Clients will invokes this service to get the token and send the token and the file to this port.
func NewFileTransfer ¶ added in v1.4.1
func NewFileTransfer(addr string, handler FileTransferHandler, downloadFileHandler DownloadFileHandler, waitNum int) *FileTransfer
NewFileTransfer creates a FileTransfer with given parameters.
func (*FileTransfer) Start ¶ added in v1.4.1
func (s *FileTransfer) Start() error
func (*FileTransfer) Stop ¶ added in v1.4.1
func (s *FileTransfer) Stop() error
type FileTransferArgs ¶ added in v1.4.1
type FileTransferArgs struct {
FileName string `json:"file_name,omitempty"`
FileSize int64 `json:"file_size,omitempty"`
Meta map[string]string `json:"meta,omitempty"`
}
FileTransferArgs args from clients.
type FileTransferHandler ¶ added in v1.4.1
type FileTransferHandler func(conn net.Conn, args *FileTransferArgs)
FileTransferHandler handles uploading file. Must close the connection after it finished.
type FileTransferReply ¶ added in v1.4.1
type FileTransferReply struct {
Token []byte `json:"token,omitempty"`
Addr string `json:"addr,omitempty"`
}
FileTransferReply response to token and addr to clients.
type FileTransferService ¶ added in v1.4.1
type FileTransferService struct {
FileTransfer *FileTransfer
}
func (*FileTransferService) DownloadFile ¶ added in v1.4.1
func (s *FileTransferService) DownloadFile(ctx context.Context, args *DownloadFileArgs, reply *FileTransferReply) error
func (*FileTransferService) TransferFile ¶ added in v1.4.1
func (s *FileTransferService) TransferFile(ctx context.Context, args *FileTransferArgs, reply *FileTransferReply) 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 ¶
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 ¶ added in v1.4.1
func (p *MDNSRegisterPlugin) Stop() error
Stop unregister all services.
func (*MDNSRegisterPlugin) Unregister ¶ added in v1.4.1
func (p *MDNSRegisterPlugin) Unregister(name string) (err error)
type MetricsPlugin ¶
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 ¶
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, "http://127.0.0.1:8086","metrics", "test","test"})
func (*MetricsPlugin) InfluxDBWithTags ¶ added in v1.4.1
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 ¶
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
type OpenCensusPlugin ¶ added in v1.4.1
type OpenCensusPlugin struct{}
func (OpenCensusPlugin) PostConnAccept ¶ added in v1.4.1
func (OpenCensusPlugin) PostWriteResponse ¶ added in v1.4.1
func (OpenCensusPlugin) PreHandleRequest ¶ added in v1.4.1
func (OpenCensusPlugin) Register ¶ added in v1.4.1
func (p OpenCensusPlugin) Register(name string, rcvr interface{}, metadata string) error
func (OpenCensusPlugin) RegisterFunction ¶ added in v1.4.1
func (p OpenCensusPlugin) RegisterFunction(name string, fn interface{}, metadata string) error
type OpenTracingPlugin ¶ added in v1.4.1
type OpenTracingPlugin struct{}
func (OpenTracingPlugin) PostConnAccept ¶ added in v1.4.1
func (OpenTracingPlugin) PostWriteResponse ¶ added in v1.4.1
func (OpenTracingPlugin) PreHandleRequest ¶ added in v1.4.1
func (OpenTracingPlugin) Register ¶ added in v1.4.1
func (p OpenTracingPlugin) Register(name string, rcvr interface{}, metadata string) error
func (OpenTracingPlugin) RegisterFunction ¶ added in v1.4.1
func (p OpenTracingPlugin) RegisterFunction(name string, fn interface{}, metadata string) error
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
type TracePlugin ¶
type TracePlugin struct {
}
func (*TracePlugin) PostConnAccept ¶
func (*TracePlugin) PostReadRequest ¶
func (*TracePlugin) PostWriteResponse ¶
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