Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidEtcdPrefix = errors.New("invalid etcd prefix") ErrInvalidTargetName = errors.New("invalid target name") ErrInvalidServerName = errors.New("invalid server name") )
var ( // PlatformOptions provides functional options for configuring RPCPlatform. PlatformOptions = options.Platform{} // ClientOptions provides functional options for configuring Client. ClientOptions = options.Client{} // ServerOptions provides functional options for configuring Server. ServerOptions = options.Server{} )
Functions ¶
This section is empty.
Types ¶
type Attributes ¶
type Attributes = attributes.Attributes
Attributes contains server attribute values.
func NewAttributes ¶ added in v1.5.0
func NewAttributes() *Attributes
NewAttributes returns new Attributes with default values.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Client ¶
func (c *Client) Client() *grpc.ClientConn
Client returns the underlying gRPC ClientConn.
type ClientOption ¶ added in v1.5.0
ClientOption is a functional option that configures a Client.
type PlatformOption ¶ added in v1.5.0
PlatformOption is a functional option that configures an RPCPlatform.
type RPCPlatform ¶
type RPCPlatform struct {
// contains filtered or unexported fields
}
func New ¶
func New(etcdPrefix string, etcdClient *etcd.Client, options ...PlatformOption) (*RPCPlatform, error)
New creates a new RPCPlatform for creating clients and servers. You can create one RPCPlatform instance and reuse it throughout your program. All RPCPlatform methods are thread-safe.
func (*RPCPlatform) Lookup ¶ added in v1.4.0
func (p *RPCPlatform) Lookup(ctx context.Context, target string, watch bool) (<-chan map[string]*ServerInfo, error)
Lookup returns information about available servers with the given name. If watch is true, the returned channel sends updates whenever servers change. If watch is false, the channel closes after the first update. The returned map keys are server IDs.
func (*RPCPlatform) NewClient ¶
func (p *RPCPlatform) NewClient(target string, options ...ClientOption) (*Client, error)
NewClient creates a new client connecting to the specified server name.
func (*RPCPlatform) NewServer ¶
func (p *RPCPlatform) NewServer(name, addr string, options ...ServerOption) (*Server, error)
NewServer creates a new server with the given name listening on addr. If addr is empty, the server listens on all available interfaces. If the port is 0, a random available port is automatically assigned.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
type ServerInfo ¶ added in v1.5.0
type ServerInfo struct {
Address string
Attributes *Attributes
}
ServerInfo contains information about a server stored in etcd.
type ServerOption ¶ added in v1.5.0
ServerOption is a functional option that configures a Server.

