package datakit

import "github.com/moby/datakit/api/go-datakit"

The datakit package contains common patterns over 9P, which avoids the need for applications to use 9P directly.

Index

Variables

var InitialVersion = Version(0)

Functions

func Head(ctx context.Context, client *Client, fromBranch string) (string, error)

Head retrieves the commit sha of the given branch

func NewTransaction

func NewTransaction(ctx context.Context, client *Client, fromBranch string) (*transaction, error)

NewTransaction opens a new transaction originating from fromBranch, named newBranch.

Types

type BoolField

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

func (*BoolField) Get

func (f *BoolField) Get() (bool, Version)

Get retrieves the current value of the key

func (*BoolField) HasChanged

func (f *BoolField) HasChanged(version Version) bool

HasChanged returns true if the key has changed since the given version

type Client

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

func Dial

func Dial(ctx context.Context, network, address string) (*Client, error)

Dial opens a connection to a 9P server

func NewClient

func NewClient(ctx context.Context, conn net.Conn) (*Client, error)

NewClient creates opens a connection with the p9p server

func (*Client) Close

func (c *Client) Close(ctx context.Context)

func (*Client) Create

func (c *Client) Create(ctx context.Context, path ...string) (*File, error)

Create creates a file

func (*Client) List

func (c *Client) List(ctx context.Context, path []string) ([]string, error)

List a directory

func (*Client) Mkdir

func (c *Client) Mkdir(ctx context.Context, path ...string) error

Mkdir acts like 'mkdir -p'

func (*Client) Open

func (c *Client) Open(ctx context.Context, mode p9p.Flag, path ...string) (*File, error)

Open opens a file

func (*Client) Remove

func (c *Client) Remove(ctx context.Context, path ...string) error

Remove acts like 'rm -f'

type File

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

func (*File) Close

func (f *File) Close(ctx context.Context)

Close closes a file

func (*File) NewFileReader

func (f *File) NewFileReader(ctx context.Context) *FileReader

func (*File) NewIOReader

func (f *File) NewIOReader(ctx context.Context, offset int64) io.Reader

NewIOReader creates a standard io.Reader at a given position in the file

func (*File) NewIOWriter

func (f *File) NewIOWriter(ctx context.Context, offset int64) io.Writer

NewIOWriter creates a standard io.Writer at a given position in the file

func (*File) Read

func (f *File) Read(ctx context.Context, p []byte, offset int64) (int, error)

Read reads a value

func (*File) Write

func (f *File) Write(ctx context.Context, p []byte, offset int64) (int, error)

Write writes a value

type FileReader

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

func (*FileReader) Read

func (f *FileReader) Read(p []byte) (int, error)

type IntField

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

func (*IntField) Get

func (f *IntField) Get() (int, Version)

Get retrieves the current value of the key

func (*IntField) HasChanged

func (f *IntField) HasChanged(version Version) bool

HasChanged returns true if the key has changed since the given version

type Record

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

Record is a typed view on top of a database branch

func NewRecord

func NewRecord(ctx context.Context, client *Client, lookupB []string, defaultsB string, stateB string, path []string) (*Record, error)

func (*Record) BoolField

func (f *Record) BoolField(key string, value bool) *BoolField

BoolField defines an boolean option with a specified key and default value

func (*Record) IntField

func (f *Record) IntField(key string, value int) *IntField

IntField defines an boolean option with a specified key and default value

func (*Record) Seal

func (r *Record) Seal(ctx context.Context) error

func (*Record) SetMultiple

func (r *Record) SetMultiple(description string, fields []*StringField, values []string) error

func (*Record) StringField

func (f *Record) StringField(key string, value string) *StringField

StringField defines a string

func (*Record) StringRefField

func (f *Record) StringRefField(key string, value *string) *StringRefField

StringRefField defines a string option which can be nil with a specified key and default value

func (*Record) Upgrade

func (r *Record) Upgrade(ctx context.Context, schemaVersion int) error

func (*Record) Wait

func (r *Record) Wait(ctx context.Context) error

type Snapshot

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

func NewSnapshot

func NewSnapshot(ctx context.Context, client *Client, kind SnapshotKind, thing string) *Snapshot

NewSnapshot opens a new snapshot referencing the given object.

func (*Snapshot) List

func (s *Snapshot) List(ctx context.Context, path []string) ([]string, error)

List returns filenames list in directory

func (*Snapshot) Read

func (s *Snapshot) Read(ctx context.Context, path []string) (string, error)

Read reads a value from the snapshot

type SnapshotKind

type SnapshotKind uint8
const (
	COMMIT SnapshotKind = 0x01 // from a commit hash
	OBJECT SnapshotKind = 0x02 // from an object hash
)

type StringField

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

func (*StringField) Get

func (f *StringField) Get() (string, Version)

Get retrieves the current value of the key

func (*StringField) HasChanged

func (f *StringField) HasChanged(version Version) bool

HasChanged returns true if the key has changed since the given version

func (*StringField) Set

func (f *StringField) Set(description string, value string) error

Set unconditionally sets the value of the key

type StringRefField

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

func (*StringRefField) Get

func (f *StringRefField) Get() (*string, Version)

Get retrieves the current value of the key

func (*StringRefField) HasChanged

func (f *StringRefField) HasChanged(version Version) bool

HasChanged returns true if the key has changed since the given version

func (*StringRefField) Set

func (f *StringRefField) Set(description string, value *string) error

Set unconditionally sets the value of the key

type Version

type Version int

type Watch

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

func NewWatch

func NewWatch(ctx context.Context, client *Client, fromBranch string, path []string) (*Watch, error)

NewWatch starts watching a path within a branch

func (*Watch) Close

func (w *Watch) Close(ctx context.Context)

func (*Watch) Next

func (w *Watch) Next(ctx context.Context) (*Snapshot, error)

Source Files

client.go config.go doc.go snapshot.go transaction.go watch.go

Version
v1.0.0 (latest)
Published
Jul 12, 2019
Platform
js/wasm
Imports
11 packages
Last checked
now

Tools for package owners.