diskrpc

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dump

func Dump(nodes []*node) string

Dump the tree to a string builder. Useful for debugging.

func NewMailBox

func NewMailBox(localID MailBoxID, locker sync.Locker, dataFile string) (*mailBox, error)

Types

type Addr

type Addr int32

An allocated address.

type Allocator

type Allocator []*node

Allocator is defined as an array of nodes and implements a buddy allocator.

func NewAllocatorByNodeCnt

func NewAllocatorByNodeCnt(nodeCnt int) (Allocator, error)

func NewAllocatorBySize

func NewAllocatorBySize(size int32) (Allocator, error)

func (*Allocator) Alloc

func (nodes *Allocator) Alloc(size int32) (Addr, error)

func (*Allocator) Free

func (nodes *Allocator) Free(addr Addr) error

type Channel

type Channel uint8

Multiplexer channel for RPC handlers.

type DiskRpc

type DiskRpc interface {
	// Register a handler for the given channel. Use a nil handler to unregister
	// a target.
	Register(channel Channel, handler interface{}) error

	// Handle incoming and outgoing messages.
	Handle(ctx context.Context) error

	// Execute an RPC call.
	Invoke(ctx context.Context, nodeID MailBoxID, targetID Channel, method string, req proto.Message, res proto.Message) error
}

DiskRpc implements a synchronous RPC mechanism.

func NewDiskRpc

func NewDiskRpc(mb MailBox) (DiskRpc, error)

type MailBox

type MailBox interface {
	// Retrieve the local mailbox id.
	LocalID() MailBoxID

	// Receive messages from the mail box.
	//
	// This call will block until there is something to read.
	Recv() ([]*Message, error)

	// Send a message.
	Send(msg *Message) error
}

A MailBox is an interface that allows unicast message communication.

type MailBoxID

type MailBoxID uint16

An identifier to identify mailboxes. Valid ranges are 0-2000. 0 is treated as a special value to identify the local mailbox.

type Message

type Message struct {
	Sender    MailBoxID
	Recipient MailBoxID
	Payload   []byte
}

A mailbox message.

Jump to

Keyboard shortcuts

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