server

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Listen

func Listen(conf *cmd.Conf, log zerolog.Logger, gs *grpc.Server)

Listen will start the GRPC server and listen on the configured port/host.

func NewGRPCServer

func NewGRPCServer(conf *cmd.Conf, l zerolog.Logger, cdb *database.CapybaraDB) (*grpc.Server, error)

NewGRPCServer will create a new GRPC server given the proper configuration, logger and database config.

Types

type CapybaraServer

type CapybaraServer struct {
	pb.UnimplementedCapybaraServer
	// contains filtered or unexported fields
}

CapybaraServer represents the GRPC server.

func (*CapybaraServer) AuthInterceptor

func (cap *CapybaraServer) AuthInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

AuthInterceptor intercepts incoming grpc calls and will fetch the authentication token in the context TODO: True check.

func (*CapybaraServer) ClaimLock

func (cap *CapybaraServer) ClaimLock(ctx context.Context, lr *pb.LockRequest) (*pb.LockResponse, error)

ClaimLock implements the CapybaraServer interface. This function can be used to acquire a lock. If the lock is already owned by another owner, the function will return the lock's details such as its expiration date, creation date and who the owner is.

func (*CapybaraServer) Delete

Delete will delete data from the kv store.

func (*CapybaraServer) Get

func (cap *CapybaraServer) Get(ctx context.Context, gr *pb.GetRequest) (*pb.GetResponse, error)

Get will return data from the kv store (if any).

func (*CapybaraServer) Put

func (cap *CapybaraServer) Put(ctx context.Context, pr *pb.PutRequest) (*pb.PutResponse, error)

Put will insert data in the kv store.

func (*CapybaraServer) ReleaseLock

func (cap *CapybaraServer) ReleaseLock(ctx context.Context, rr *pb.ReleaseRequest) (*pb.ReleaseResponse, error)

ReleaseLock is used to release a lock. This method will only work if the client has ownership on the lock.

Jump to

Keyboard shortcuts

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