Documentation
¶
Index ¶
- Variables
- type BindFuc
- type Message
- type NewRPCServer
- type Option
- func Address(a string) Option
- func ID(id string) Option
- func Metadata(md map[string]string) Option
- func Name(n string) Option
- func Port(a int) Option
- func RPCBind(fnc func(*grpc.Server)) Option
- func RegisterInterval(t time.Duration) Option
- func RegisterTTL(t time.Duration) Option
- func Registry(r reg.Registry) Option
- func RegistryEnable(status bool) Option
- func Version(v string) Option
- func Wait(b bool) Option
- type Options
- type RPCClient
- type RPCServer
- type RPCServerI
- type Request
- type Server
- type Stream
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefaultAddress DefaultAddress DefaultAddress = ":19000" // DefaultName DefaultName DefaultName = "go-server" // DefaultVersion DefaultVersion DefaultVersion = "1.0.0" // DefaultID DefaultID DefaultID = guuid.New().String() )
Functions ¶
This section is empty.
Types ¶
type NewRPCServer ¶
type NewRPCServer func() (RPCServerI, error)
type Option ¶
type Option func(*Options)
Option Option
func RegisterInterval ¶
RegisterInterval specifies the interval on which to re-register
func RegisterTTL ¶
RegisterTTL Register the service with a TTL
type Options ¶
type Options struct {
RegistryEnable bool
Registry reg.Registry
Metadata map[string]string
Name string
Address string
Port int
ID string
Version string
RegisterInterval time.Duration
RegisterTTL time.Duration
//RPCBind 服务端grpc注册
RPCBind func(*grpc.Server)
Context context.Context
}
Options Options
type RPCClient ¶
type RPCClient interface {
Call(ctx context.Context, _func string, params ...interface{}) (interface{}, string)
CallArgs(ctx context.Context, _func string, ArgsType []string, args [][]byte) (interface{}, string)
}
RPCClient 客户端定义
type RPCServer ¶
type RPCServerI ¶
RPCServerI 服务定义
type Request ¶
type Request interface {
Service() string
Method() string
ContentType() string
Request() interface{}
// indicates whether the request will be streamed
Stream() bool
}
Request Request
type Server ¶
type Server interface {
Options() Options
OnInit(*glog.Logger) error
Init(...Option) error
Register(f func(s *grpc.Server))
ServiceRegister() error
ServiceDeregister() error
Start(bind BindFuc, tracing bool) error
Stop() error
OnDestroy() error
String() string
ID() string
Port() int
GetRpcServer() *grpc.Server
}
Server is a simple micro server abstraction
type Stream ¶
type Stream interface {
Context() context.Context
Request() Request
Send(interface{}) error
Recv(interface{}) error
Error() error
Close() error
}
Stream represents a stream established with a client. A stream can be bidirectional which is indicated by the request. The last error will be left in Error(). EOF indicated end of the stream.
Click to show internal directories.
Click to hide internal directories.