grpcsrv

package
v0.6.0-alpha Latest Latest
Warning

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

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

Documentation

Overview

Package grpcsrv implements gRPC server.

See Protobuf specification at https://github.com/nmezhenskyi/rcs/blob/main/api/protobuf/rcs.proto.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	pb.UnimplementedCacheServiceServer // Embed for forward compatibility.

	Logger zerolog.Logger // By defaut Logger is disabled, but can be manually attached.
	// contains filtered or unexported fields
}

Server implements RCS gRPC service.

func NewServer

func NewServer(c *cache.CacheMap, opts ...grpc.ServerOption) *Server

NewServer initializes a new grpc Server instance ready to be used and returns a pointer to it. A zerolog.Logger can be attached to returned Server by accessing public field Server.Logger.

func (*Server) Close

func (s *Server) Close()

Close immediately closes all active connections and listeners. For a graceful shutdown, use Shutdown.

func (*Server) Delete

func (s *Server) Delete(ctx context.Context, in *pb.DeleteRequest) (*pb.DeleteReply, error)

func (*Server) Get

func (s *Server) Get(ctx context.Context, in *pb.GetRequest) (*pb.GetReply, error)

func (*Server) Keys

func (s *Server) Keys(ctx context.Context, in *pb.KeysRequest) (*pb.KeysReply, error)

func (*Server) Length

func (s *Server) Length(ctx context.Context, in *pb.LengthRequest) (*pb.LengthReply, error)

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(addr string) error

ListenAndServe listens on the given TCP network address addr and handles gRPC requests on incoming connections according to CacheService specification.

func (*Server) ListenAndServeTLS

func (s *Server) ListenAndServeTLS(addr, certFile, keyFile string) error

ListenAndServeTLS listens on the given TCP network address addr and handles gRPC requests on incoming TLS connections according to CacheService specification.

Requires valid certificate and key files containing PEM encoded data.

func (*Server) Ping

func (s *Server) Ping(ctx context.Context, in *pb.PingRequest) (*pb.PingReply, error)

func (*Server) Purge

func (s *Server) Purge(ctx context.Context, in *pb.PurgeRequest) (*pb.PurgeReply, error)

func (*Server) Set

func (s *Server) Set(ctx context.Context, in *pb.SetRequest) (*pb.SetReply, error)

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the server without interrupting any active connections. Accepts context with timeout that will forcefully close the server if timeout runs out.

Jump to

Keyboard shortcuts

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