middleware

package
v0.0.0-...-5b6cbe3 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

README

Datapath

Is the end-to-end path from the client to the devices client - processor = processor = devices

In the local datapath all the processors are running locally

OnlyLocalDapath indicated that all the Processors are running locally Otherwise, see Authority Peer (from device manager)

// Optionally make the query functions of the device manager accessible through the network
// This is need when the Authority Device Manager is other than the local Device Manager
// (the case for datapaths that span across several nodes)

Documentation

Index

Constants

View Source
const (
	// View is the mode for retreving key information without locking
	VIEW = Mode(iota)
	// RDONLY is the mode for retreving key information with locking
	RDONLY
	// WRONLY appends changes to the log of the key
	WRONLY
)

Variables

View Source
var (
	// ErrMiddleware is the root of errors caused by Middleware
	ErrMiddleware = errors.NewClass("Middleware Error")
	ErrArg        = ErrMiddleware.NewClass("Argument error")
	ErrRuntime    = ErrMiddleware.NewClass("Runtime error")

	// Generic family errors
	ErrBackend = ErrMiddleware.New("Backend error")

	// Argument family errors
	ErrInvalid    = ErrArg.New("Invalid argument")
	ErrInvalidKey = ErrArg.New("Invalid key")

	// Runtime family errors
	ErrOutOfRange = ErrRuntime.New("Out of range")
	ErrTooLarge   = ErrRuntime.New("Too large")
	ErrReadOnly   = ErrRuntime.New("File handle is read only")
	ErrWriteOnly  = ErrRuntime.New("File handle is write only")
	ErrNotADir    = ErrRuntime.New("Not a dir")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	ProcessorManager   *processormanager.ProcessorManager
	DeviceManager      *devicemanager.DeviceManager
	CoordinatorManager *coordinatormanager.CoordinatorManager
	Datapath           processor.Processor
	// contains filtered or unexported fields
}

Client provides access to the backend proxies

func NewClient

func NewClient(config Config) (*Client, error)

NewClient returns a middleware client

func (*Client) BeginTx

func (client *Client) BeginTx(key string, mode Mode) (*Tx, error)

func (*Client) Close

func (client *Client) Close() error

Close closes the client

func (*Client) CreateIfNotExist

func (client *Client) CreateIfNotExist(key string) error

CreateIfNotExist creates the log the key from the respective Coordinator

func (*Client) CreateOrReset

func (client *Client) CreateOrReset(key string) error

CreateOrReset ensures the log the key from the respective Coordinator

func (*Client) ImportFrom

func (client *Client) ImportFrom(deviceID string) error

func (*Client) Remove

func (client *Client) Remove(key string) error

Remove deletes the log for the key from the respective Coordinator

func (*Client) Truncate

func (client *Client) Truncate(key string) error

Truncate resets the log the key from the respective Coordinator

type Config

type Config struct {
	Manifest manifest.Manifest `validate:"required"`
}

Config is the configuration for the middleware client

type Cursor

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

func (*Cursor) ForEach

func (c *Cursor) ForEach(fn func(stx *SubTx) bool)

ForEach executes a function for each delta in the transaction. If false, stop iteration

type Mode

type Mode uint8

Mode defines the type of the transaction

func (Mode) String

func (m Mode) String() string

Return a string representation instead of a numerical

type SubTx

type SubTx struct {
	Offset int `json:"Offset"`
	Size   int `json:"Size"`

	processor.Stream
}

type Tx

type Tx struct {

	// UpdateTx
	SubTxs []*SubTx `json:"SubTxs,omitempty"`

	Sinks map[string]string `json:"Sinks,omitempty"`

	// transaction identifier
	TID string `json:"TID,omitempty"`
	// contains filtered or unexported fields
}

func (*Tx) Commit

func (tx *Tx) Commit() error

Commit writes all changes to the devices and updates the meta page on coordinators Returns an error if a device write error occurs, or if Commit is called on a read-only transaction.

func (*Tx) Cursor

func (tx *Tx) Cursor() *Cursor

func (*Tx) Get

func (tx *Tx) Get(segment uint64) (int, []byte, error)

We want the reader to be stateless, but doing so when blocks are involved is tricky. Offset M may not be aligned with block begin at offset N. In order to navigate correctly the metadata within the block the client must position with M-N (alpabetically ordered)

func (*Tx) ID

func (tx *Tx) ID() string

ID returns the transaction id

func (*Tx) Key

func (tx *Tx) Key() string

func (*Tx) Rollback

func (tx *Tx) Rollback()

Rollback closes the transaction and ignores all previous updates. Read-only transactions must be rolled back and not committed.

func (*Tx) Update

func (tx *Tx) Update(offset int64, fn func(pw io.ReadWriteCloser) (int, error)) error

Directories

Path Synopsis
datapath
libio

Jump to

Keyboard shortcuts

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