fred

package
v0.2.19 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Addr string
	IsIP bool
}

Address is an IP address or a hostname of a FReD node.

type Client

type Client interface {
	SendCreateKeygroup(host string, kgname KeygroupName, expiry int) error
	SendDeleteKeygroup(host string, kgname KeygroupName) error
	SendUpdate(host string, kgname KeygroupName, id string, value string, tombstoned bool, vvector vclock.VClock) error
	SendAppend(host string, kgname KeygroupName, id string, value string) error
	SendGetItem(host string, kgname KeygroupName, id string) ([]Item, error)
	SendGetAllItems(host string, kgname KeygroupName) ([]Item, error)
}

Client is an interface to send replication messages across nodes.

type Config

type Config struct {
	Store                   Store
	Client                  Client
	NaSe                    NameService
	PeeringHost             string
	PeeringHostProxy        string
	PeeringAsyncReplication bool
	ExternalHost            string
	ExternalHostProxy       string
	NodeID                  string
	TriggerCert             string
	TriggerKey              string
	TriggerCA               []string
}

Config holds configuration parameters for an instance of FReD.

type ExtHandler

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

func (*ExtHandler) HandleAddReplica

func (h *ExtHandler) HandleAddReplica(user string, k Keygroup, n Node) error

HandleAddReplica handles requests to the AddKeygroupReplica endpoint of the client interface.

func (*ExtHandler) HandleAddTrigger

func (h *ExtHandler) HandleAddTrigger(user string, k Keygroup, t Trigger) error

HandleAddTrigger handles requests to the AddKeygroupTrigger endpoint of the client interface.

func (*ExtHandler) HandleAddUser

func (h *ExtHandler) HandleAddUser(user string, newuser string, k Keygroup, r Role) error

HandleAddUser adds permissions to a keygroup to a new user.

func (*ExtHandler) HandleAppend

func (h *ExtHandler) HandleAppend(user string, i Item) (Item, error)

HandleAppend handles requests to the Append endpoint of the client interface.

func (*ExtHandler) HandleCreateKeygroup

func (h *ExtHandler) HandleCreateKeygroup(user string, k Keygroup) error

HandleCreateKeygroup handles requests to the CreateKeygroup endpoint of the client interface.

func (*ExtHandler) HandleDelete

func (h *ExtHandler) HandleDelete(user string, i Item, versions []vclock.VClock) (Item, error)

HandleDelete handles requests to the Delete endpoint of the client interface.

func (*ExtHandler) HandleDeleteKeygroup

func (h *ExtHandler) HandleDeleteKeygroup(user string, k Keygroup) error

HandleDeleteKeygroup handles requests to the DeleteKeygroup endpoint of the client interface.

func (*ExtHandler) HandleGetAllReplica

func (h *ExtHandler) HandleGetAllReplica(_ string) ([]Node, error)

HandleGetAllReplica handles requests to the GetAllReplica endpoint of the client interface.

func (*ExtHandler) HandleGetKeygroupInfo added in v0.2.2

func (h *ExtHandler) HandleGetKeygroupInfo(user string, k Keygroup) (bool, []Node, map[NodeID]int, error)

HandleGetKeygroupInfo handles requests to the GetKeygroupInfo endpoint of the client interface.

func (*ExtHandler) HandleGetKeygroupTriggers

func (h *ExtHandler) HandleGetKeygroupTriggers(user string, k Keygroup) ([]Trigger, error)

HandleGetKeygroupTriggers handles requests to the GetKeygroupTrigger endpoint of the client interface.

func (*ExtHandler) HandleGetReplica

func (h *ExtHandler) HandleGetReplica(_ string, n Node) (Node, error)

HandleGetReplica handles requests to the GetReplica endpoint of the client interface.

func (*ExtHandler) HandleKeys added in v0.2.19

func (h *ExtHandler) HandleKeys(user string, i Item, count uint64) ([]Item, error)

HandleKeys handles requests to the Scan endpoint of the client interface.

func (*ExtHandler) HandleRead

func (h *ExtHandler) HandleRead(user string, i Item, versions []vclock.VClock) ([]Item, error)

HandleRead handles requests to the Read endpoint of the client interface.

func (*ExtHandler) HandleRemoveReplica

func (h *ExtHandler) HandleRemoveReplica(user string, k Keygroup, n Node) error

HandleRemoveReplica handles requests to the RemoveKeygroupReplica endpoint of the client interface.

func (*ExtHandler) HandleRemoveTrigger

func (h *ExtHandler) HandleRemoveTrigger(user string, k Keygroup, t Trigger) error

HandleRemoveTrigger handles requests to the RemoveKeygroupTrigger endpoint of the client interface.

func (*ExtHandler) HandleRemoveUser

func (h *ExtHandler) HandleRemoveUser(user string, newuser string, k Keygroup, r Role) error

HandleRemoveUser removes permissions to a keygroup to a user.

func (*ExtHandler) HandleScan

func (h *ExtHandler) HandleScan(user string, i Item, count uint64) ([]Item, error)

HandleScan handles requests to the Scan endpoint of the client interface.

func (*ExtHandler) HandleUpdate

func (h *ExtHandler) HandleUpdate(user string, i Item, versions []vclock.VClock) (Item, error)

HandleUpdate handles requests to the Update endpoint of the client interface.

type Fred

type Fred struct {
	E *ExtHandler
	I *IntHandler
}

Fred is an instance of FReD.

func New

func New(config *Config) (f Fred)

New creates a new FReD instance.

type IntHandler

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

func (*IntHandler) HandleAppend

func (h *IntHandler) HandleAppend(i Item) error

HandleAppend handles requests to the Append endpoint of the internal interface.

func (*IntHandler) HandleCreateKeygroup

func (h *IntHandler) HandleCreateKeygroup(k Keygroup) error

HandleCreateKeygroup handles requests to the CreateKeygroup endpoint of the internal interface.

func (*IntHandler) HandleDeleteKeygroup

func (h *IntHandler) HandleDeleteKeygroup(k Keygroup) error

HandleDeleteKeygroup handles requests to the DeleteKeygroup endpoint of the internal interface.

func (*IntHandler) HandleGet

func (h *IntHandler) HandleGet(i Item) ([]Item, error)

HandleGet handles requests to the Get endpoint of the internal interface.

func (*IntHandler) HandleGetAllItems

func (h *IntHandler) HandleGetAllItems(k Keygroup) ([]Item, error)

HandleGetAllItems handles requests to the Get endpoint of the internal interface.

func (*IntHandler) HandleUpdate

func (h *IntHandler) HandleUpdate(i Item) error

HandleUpdate handles requests to the Update endpoint of the internal interface.

type Item

type Item struct {
	Keygroup   KeygroupName
	ID         string
	Val        string
	Version    vclock.VClock
	Tombstoned bool
}

Item is an item in the key-value store.

type Keygroup

type Keygroup struct {
	Name    KeygroupName
	Mutable bool
	Expiry  int
}

Keygroup has a name and a list of replica nodes and trigger nodes.

type KeygroupName

type KeygroupName string

KeygroupName is a name of a keygroup.

type Method

type Method string

Method is a representation of all methods a client could perform on a keygroup.

const (
	CreateKeygroup Method = "CreateKeygroup"
	DeleteKeygroup Method = "DeleteKeygroup"
	Read           Method = "Read"
	Update         Method = "Update"
	Delete         Method = "Delete"
	AddReplica     Method = "AddReplica"
	GetReplica     Method = "GetReplica"
	RemoveReplica  Method = "RemoveReplica"
	GetAllReplica  Method = "GetAllReplica"
	GetTrigger     Method = "GetTrigger"
	AddTrigger     Method = "AddTrigger"
	RemoveTrigger  Method = "RemoveTrigger"
	AddUser        Method = "AddUser"
	RemoveUser     Method = "RemoveUser"
)

These are all methods that clients can perform on FReD, implemented as constants for easier use.

type NameService

type NameService interface {
	// manage information about this node
	GetNodeID() NodeID
	RegisterSelf(host string, externalHost string) error

	// manage permissions
	AddUserPermissions(user string, method Method, keygroup KeygroupName) error
	RevokeUserPermissions(user string, method Method, keygroup KeygroupName) error
	GetUserPermissions(user string, keygroup KeygroupName) (map[Method]struct{}, error)

	// get information about a keygroup
	IsMutable(kg KeygroupName) (bool, error)
	GetExpiry(kg KeygroupName) (int, error)

	// manage information about another node
	GetNodeAddress(nodeID NodeID) (addr string, err error)
	GetNodeAddressExternal(nodeID NodeID) (addr string, err error)
	GetAllNodes() (nodes []Node, err error)
	GetAllNodesExternal() (nodes []Node, err error)

	// manage keygroups
	ExistsKeygroup(kg KeygroupName) (bool, error)
	JoinNodeIntoKeygroup(kg KeygroupName, nodeID NodeID, expiry int) error
	ExitOtherNodeFromKeygroup(kg KeygroupName, nodeID NodeID) error
	CreateKeygroup(kg KeygroupName, mutable bool, expiry int) error
	DeleteKeygroup(kg KeygroupName) error
	GetKeygroupMembers(kg KeygroupName, excludeSelf bool) (ids map[NodeID]int, err error)

	// handle node failures
	ReportFailedNode(nodeID NodeID, kg KeygroupName, id string) error
	RequestNodeStatus(nodeID NodeID) []Item
	GetNodeWithBiggerExpiry(kg KeygroupName) (nodeID NodeID, addr string)
}

NameService interface abstracts from the features of the nameservice, whether that is etcd or a distributed implementation.

type Node

type Node struct {
	ID   NodeID
	Host string
}

Node is a replica node.

type NodeID

type NodeID string

NodeID is an identifier of a replica node.

type Role

type Role string

Role is a wrapper for a set of permissions/methods.

const (
	ReadKeygroup       Role = "R"
	WriteKeygroup      Role = "W"
	ConfigureReplica   Role = "C"
	ConfigureTrigger   Role = "T"
	ConfigureKeygroups Role = "K"
)

These are all roles that we have in FReD.

type Store

type Store interface {
	// Update Needs: keygroup, id, val
	Update(kg string, id string, val string, expiry int, vvector vclock.VClock) error
	// Delete Needs: keygroup, id
	Delete(kg string, id string, vvector vclock.VClock) error
	// Append Needs: keygroup, val, Returns: key
	Append(kg string, id string, val string, expiry int) error
	// Read Needs: keygroup, id; Returns: val, version vector, found
	Read(kg string, id string) ([]string, []vclock.VClock, bool, error)
	// ReadSome Needs: keygroup, id, range; Returns: ids, values, versions
	ReadSome(kg string, id string, count uint64) ([]string, []string, []vclock.VClock, error)
	// ReadAll Needs: keygroup; Returns: ids, values, versions
	ReadAll(kg string) ([]string, []string, []vclock.VClock, error)
	// IDs Needs: keygroup, Returns:[] keygroup, id
	IDs(kg string) ([]string, error)
	// Exists Needs: keygroup, id
	Exists(kg string, id string) bool
	// CreateKeygroup Needs: keygroup, Returns: err
	// Doesnt really need to store the KG itself, that is keygroup/store.go's job.
	// But might be useful for databases using it
	CreateKeygroup(kg string) error
	// DeleteKeygroup Same as with CreateKeygroup
	DeleteKeygroup(kg string) error
	// ExistsKeygroup Needs: keygroup
	ExistsKeygroup(kg string) bool
	// AddKeygroupTrigger Needs: keygroup, trigger node id, trigger node host
	AddKeygroupTrigger(kg string, id string, host string) error
	// DeleteKeygroupTrigger Needs: keygroup, trigger node id
	DeleteKeygroupTrigger(kg string, id string) error
	// GetKeygroupTrigger Needs: keygroup; Returns map: trigger node id -> trigger node host
	GetKeygroupTrigger(kg string) (map[string]string, error)
	// Close indicates that the underlying store should be closed as it is no longer needed.
	Close() error
}

Store is an interface for the storage medium that the key-value val items are persisted on.

type Trigger

type Trigger struct {
	ID   string
	Host string
}

Trigger is one trigger node with an ID and a host address.

Jump to

Keyboard shortcuts

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