rpc

package
v0.0.0-...-82b0641 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultAddress          = ":0"
	DefaultName             = "stark.rpc.server"
	DefaultVersion          = time.Now().Format("2006.01.02.15.04")
	DefaultId               = uuid.New().String()
	DefaultRegisterInterval = time.Second * 30
	DefaultRegisterTTL      = time.Minute
)
View Source
var (
	DefaultTimeout = time.Second * 2
)

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(name string, s selector.Selector, opt ...ClientOption) (*Client, error)

func (*Client) Conn

func (c *Client) Conn() *grpc.ClientConn

type ClientOption

type ClientOption func(*ClientOptions)

func GrpcDialOption

func GrpcDialOption(do ...grpc.DialOption) ClientOption

func StreamClientInterceptors

func StreamClientInterceptors(u ...grpc.StreamClientInterceptor) ClientOption

func Timeout

func Timeout(t time.Duration) ClientOption

func UnaryClientInterceptor

func UnaryClientInterceptor(u ...grpc.UnaryClientInterceptor) ClientOption

type ClientOptions

type ClientOptions struct {
	Timeout time.Duration

	GrpcOpts []grpc.DialOption
}

type Server

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

func NewServer

func NewServer(rg registry.Registry, opt ...ServerOption) *Server

func (*Server) GrpcServer

func (g *Server) GrpcServer() *grpc.Server

func (*Server) Options

func (g *Server) Options() ServerOptions

func (*Server) RegisterEndpoints

func (g *Server) RegisterEndpoints(service ...interface{})

func (*Server) Start

func (g *Server) Start() error

func (*Server) Stop

func (g *Server) Stop() error

func (*Server) String

func (g *Server) String() string

type ServerOption

type ServerOption func(*ServerOptions)

func Address

func Address(a string) ServerOption

Address to bind to - host:port

func Id

func Id(id string) ServerOption

Id Unique server id

func Metadata

func Metadata(md map[string]string) ServerOption

Metadata associated with the server

func MetricsAddress

func MetricsAddress(a string) ServerOption

func MetricsPath

func MetricsPath(p string) ServerOption

func Name

func Name(n string) ServerOption

Server name

func RegisterInterval

func RegisterInterval(t time.Duration) ServerOption

RegisterInterval register the service with at interval

func RegisterTTL

func RegisterTTL(t time.Duration) ServerOption

RegisterTTL register the service with a TTL

func StreamServerInterceptor

func StreamServerInterceptor(u ...grpc.StreamServerInterceptor) ServerOption

StreamServerInterceptor to be used to configure gRPC options

func UnaryServerInterceptor

func UnaryServerInterceptor(u ...grpc.UnaryServerInterceptor) ServerOption

UnaryServerInterceptor to be used to configure gRPC options

func Version

func Version(v string) ServerOption

Version of the service

type ServerOptions

type ServerOptions struct {
	Metadata map[string]string
	Name     string
	Address  string
	Id       string
	Version  string

	MetricsPath      string
	RegisterTTL      time.Duration
	RegisterInterval time.Duration
	GrpcOpts         []grpc.ServerOption
}

Directories

Path Synopsis
client
selector/static
Package static provides a static resolver which returns the name/ip passed in without any change
Package static provides a static resolver which returns the name/ip passed in without any change
server

Jump to

Keyboard shortcuts

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