rpcplatform

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

README

RPCPlatform

Build PkgGoDev GoReportCard

An easy-to-use platform for creating microservices without complex infrastructure solutions. Only etcd required. Out of the box you get a service discovery, tracing between services and other useful things. gRPC is used for communication between services.

etcd required

If there is no etcd in your infrastructure, you can install it from a docker container for tests:

docker run -d --name etcd --env=ALLOW_NONE_AUTHENTICATION=yes -p 2379:2379 -p 2380:2380 bitnami/etcd

Of course, you can use docker in production or install etcd using your favorite package manager. Just remember that the example above is for testing purposes!

Usage examples

  • QuickStart: contains the simplest example without additional features
  • OpenTelemetry: example with connecting distributed tracing systems

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Attributes

func Attributes() attributes

Types

type Client

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

func (*Client) Client

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

Client return the original gRPC ClientConn object.

type RPCPlatform

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

func New

func New(etcdPrefix string, etcdClient *etcd.Client, opts ...options.Option) (*RPCPlatform, error)

New creates an RPCPlatform object for further creation of clients and servers. All methods of this object are thread safe. You can create this object once and use it in different places in your program.

func (*RPCPlatform) NewClient

func (p *RPCPlatform) NewClient(target string) (*Client, error)

NewClient creates a new client. You need to provide the target server name.

func (*RPCPlatform) NewServer

func (p *RPCPlatform) NewServer(name, addr string, attributes *ServerAttributes) (*Server, error)

NewServer creates a new server. You need to provide the server name, address and attributes. If no additional settings are needed, attributes can be nil.

type Server

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

func (*Server) Serve

func (s *Server) Serve() error

Serve starts the gRPC Server and return error if it occurs.

func (*Server) Server

func (s *Server) Server() *grpc.Server

Server return the original gRPC Server object.

type ServerAttributes

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

func (*ServerAttributes) SetBalancerWeight

func (sa *ServerAttributes) SetBalancerWeight(weight int)

Directories

Path Synopsis
examples
internal

Jump to

Keyboard shortcuts

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