rpc

package
v0.0.0-...-4d39105 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

package rpc includes the shared message types between client and server. Both client and server use rpc to communicate via the Msg{} type. Convinence methods are provided that wrap encoding/gob to hide the details of communication serialization from client/server. The intention is to have the Msg{} type sent as raw bytes in a HTTP POST body.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDeleteMsg

func NewDeleteMsg(key string) *bytes.Buffer

NewDeleteMsg returns a byte buffer resulting for serialization of a Delete Msg.

func NewGetMsg

func NewGetMsg(key string) *bytes.Buffer

NewGetMsg returns a byte buffer resulting for serialization of a Get Msg.

func NewSetMsg

func NewSetMsg(key string, val ValueType) *bytes.Buffer

NewSetMsg returns a byte buffer resulting for serialization of a Set Msg.

Types

type Msg

type Msg struct {
	Op    Operation
	Key   string
	Value ValueType
}

Msg is the shared type for communication between client/server. This simplifies client calls by having a single call into the server to provide all the required actions. The Value field allows for sending arbitrarily complex data as raw bytes.

func DecodeMsg

func DecodeMsg(r io.ReadCloser) *Msg

DecodeMsg converts raw bytes (assumed to be from a HTTP request) to a Msg.

type Operation

type Operation int

Operation indicates what requested action the caller is specifying.

const (
	Get Operation = iota
	Set
	Delete
)

type ValueType

type ValueType []byte

ValueType is the data type stored in the database for each key-value mapping.

Jump to

Keyboard shortcuts

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