server

package
v0.0.0-...-e3473f1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTimeout = 30 * time.Second

DefaultTimeout for making client requests to the speedmap server

Variables

This section is empty.

Functions

func Serve

func Serve(kv speedmap.Store, addr string) error

Serve the key/value store with the specified store on the specified addr.

Types

type Client

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

Client is a helper struct to connect to the speedmap server and make requests.

func NewClient

func NewClient(identity string) *Client

NewClient creates a new speedmap server client and returns it

func (*Client) Close

func (c *Client) Close() (err error)

Close the connection to the speedmap server

func (*Client) Connect

func (c *Client) Connect(addr string) (err error)

Connect to the speedmap server and prepare to make requests

func (*Client) Del

func (c *Client) Del(key string, force bool) (*pb.ClientReply, error)

Del performs a request to the speedmap server for the specified key.

func (*Client) Get

func (c *Client) Get(key string) (*pb.ClientReply, error)

Get performs a request to the speedmap server for the specified key.

func (*Client) Put

func (c *Client) Put(key string, value []byte) (*pb.ClientReply, error)

Put performs a request to the speedmap server for the specified key and value.

type Server

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

Server implements the KVServer interface and is essentially just a wrapper around a speedmap key/value Store. Note that the Server performs NO synchronization, it simply passes all requests from all clients to the speedmap. Because each request is handled in its own go routine, it is expected that the wrapped Store is thread-safe.

func New

func New(kv speedmap.Store) *Server

New creates a new server with the specified key value store.

func (*Server) Del

func (s *Server) Del(ctx context.Context, in *pb.DelRequest) (*pb.ClientReply, error)

Del handles a del request to the speedmap, relying on the speedmap for concurrent synchronization of accesses.

func (*Server) Get

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

Get handles a get request to the speedmap, relying on the speedmap for concurrent synchronization of accesses. Note that Get uses GetoOrCreate in the speedmap, storing nil as the default value; this means that this method will not return a not found error. This decision was made to more completely test the misframe implementation of the Store.

func (*Server) Listen

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

Listen for gRPC requests on the specified address and serve each request in its own go routine. The server handlers access the speed map.

func (*Server) Put

func (s *Server) Put(ctx context.Context, in *pb.PutRequest) (*pb.ClientReply, error)

Put handles a put request to the speedmap, relying on the speedmap for concurrent synchronization of accesses.

Directories

Path Synopsis
Package pb is a generated protocol buffer package.
Package pb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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