rpc

package module
v0.0.0-...-478de1d Latest Latest
Warning

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

Go to latest
Published: May 1, 2016 License: GPL-3.0 Imports: 11 Imported by: 2

README

rpc

Rpc over Http2 with service discovery

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
}

Client provides an RPC client that will find services by name

func (*Client) Dial

func (c *Client) Dial(name string) (*grpc.ClientConn, error)

Dial takes the name of a service and figures out who to dial

type Discovery

type Discovery struct {
	// contains filtered or unexported fields
}

Discovery is the main interface to all things discovery

func NewDiscovery

func NewDiscovery() (*Discovery, error)

NewDiscovery returns a new discovery initialized

func (*Discovery) DeregisterService

func (d *Discovery) DeregisterService(name string) error

DeregisterService is used to deregister a service with discovery service

func (*Discovery) GetLocalServices

func (d *Discovery) GetLocalServices() ([]*Service, error)

GetLocalServices is used to get all the services managed by the local agent

func (*Discovery) GetRandomServiceAddress

func (d *Discovery) GetRandomServiceAddress(name string) (*string, error)

func (*Discovery) GetService

func (d *Discovery) GetService(name string) ([]*Node, error)

GetService is used to get all instances of a service

func (*Discovery) RegisterService

func (d *Discovery) RegisterService(name string, port int) error

RegisterService is used to register a service with discovery service

type Node

type Node struct {
	Address string
	Port    int
}

Node represents the address of an instance of a service

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server provides an RPC server that registers itself with discovery and uses HTTP/2 transport

func (*Server) Serve

func (s *Server) Serve(name string, registrationFunc func(*grpc.Server)) error

Serve will register with discovery and wait for queries

func (*Server) Stop

func (s *Server) Stop() error

Stop will end serving and remove itself from discovery

type Service

type Service struct {
	Name string
	Node Node
}

Service represents a service

Jump to

Keyboard shortcuts

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