Documentation
¶
Overview ¶
Package store is the one place Corbie keeps anything: values with names, three ways of writing one, and the directory, bucket and memory stores.
Index ¶
- Constants
- Variables
- func Above(location string) []string
- func Blob(ctl, run, name string) string
- func Blobs(ctl, run string) string
- func Carried(ctl, run string) string
- func Certificate(key ed25519.PrivateKey) (tls.Certificate, error)
- func Check(ctx context.Context, s Store) error
- func CheckLocation(location string) error
- func CheckLocationPart(part string) error
- func CheckPart(part string) error
- func CheckPrefix(prefix string) error
- func CheckRun(name string) error
- func ChildRun(parent string, at time.Time, job string) string
- func DirectoryAt(address string) (string, error)
- func Each(ctx context.Context, limit, n int, do func(i int) error) error
- func Emit(ctl, run string, job, number int) string
- func EmitOf(ctl, run, name string) (job, number int, ok bool)
- func Emits(ctl, run string) string
- func Finished(ctl string) string
- func FinishedHead(ctl, run string) string
- func House(ctl string) string
- func Inbox(party string) string
- func IsReceiptBlob(ctl, name string) bool
- func JobMessage(run, job string) string
- func JobSubmit(at time.Time, run string, step, index int) string
- func Key(ctl, location, key string) string
- func Keys(ctl, location string) string
- func LinkMessage(from string, step, index int, what string) string
- func LocationBlob(ctl, location, name string) string
- func LocationBlobs(ctl, location string) string
- func LocationDir(ctl, location string) string
- func LocationFile(ctl, location string) string
- func Locations(ctl string) string
- func Message(party, sender, message string) string
- func MessageOf(party, name string) (sender, message string, ok bool)
- func MessageTime(message string) (time.Time, bool)
- func Names(listed []Listed, err error) ([]string, error)
- func NewRun(client string, now time.Time) string
- func Number(name string) int
- func ParseLocation(ctl, name string) (location, entry string, ok bool)
- func ParseStamp(text string) (time.Time, error)
- func ParseWake(ctl, name string) (at time.Time, run, what string, ok bool)
- func Policy(p Party, bucket, prefix string, also ...string) (string, error)
- func PolicyFor(address string, p Party, kept, name string) (string, error)
- func Receipt(ctl, sender, message string) string
- func ReceiptBlob(ctl, sender, message, name string) string
- func ReceiptBlobs(ctl, sender, message string) string
- func ReceiptMessage(ctl, name string) (message string, ok bool)
- func Receipts(ctl, sender string) string
- func Record(ctl, run string) string
- func Records(ctl string) string
- func Result(ctl, sender, message string) string
- func RootRun(client string, at time.Time, from string) string
- func RunClient(run string) string
- func RunOf(ctl, name string) string
- func RunTime(run string) (time.Time, error)
- func Running(ctl string) string
- func RunningHead(ctl, run string) string
- func Secret(ctl, at, name string) string
- func Secrets(ctl, at string) string
- func ServedListener(l net.Listener, certificate tls.Certificate) net.Listener
- func SetUp(ctx context.Context, s Store) error
- func Source(ctl, prefix string) string
- func SourceBlob(ctl, prefix, name string) string
- func Stamp(t time.Time) string
- func Step(ctl, run string, number int) string
- func Steps(ctl, run string) string
- func Taken(runner string, due time.Time, job string) string
- func TakenList(runner string) string
- func TakenOf(name string) (job string, due time.Time, ok bool)
- func Tree(ctl, prefix string) string
- func Tried(ctl, run string) string
- func Trust(ctl, party string) string
- func TrustList(ctl string) string
- func Unreported(s Store) error
- func Upload(ctl, client, message, name string) string
- func UploadOf(ctl, name string) (message string, ok bool)
- func Uploaded(ctl, client, message string) string
- func Uploads(ctl string) string
- func Value(ctl, at, name string) string
- func Values(ctl, at string) string
- func Wake(ctl string, at time.Time, run, what string) string
- func Wakes(ctl string) string
- func WriteForward(ctx context.Context, s Store, name string, value []byte, ...) (bool, error)
- type Act
- type AddressKind
- type How
- type Kind
- type Listed
- type Mark
- type Memory
- type Op
- type Party
- type Proof
- type Sender
- type Server
- type Store
Constants ¶
const ServedScheme = "corbie://"
ServedScheme begins the address of a directory that another computer serves: corbie://host:port.
const SideBySide = 16
SideBySide is how many requests one Bounded store has open at once by default: the store of one controller pass, one start or one definition made while a machine runs; and how many of the values a listing names a watcher or a follower reads at once.
const Version = 2
Version is the layout this Corbie knows.
const VersionName = "version"
VersionName is the name of the value that holds the layout's version.
Variables ¶
var ( // Overwrite writes, or deletes, whatever is there. Overwrite = How{/* contains filtered or unexported fields */} // OnlyIfNew writes only if nothing has the name yet. OnlyIfNew = How{/* contains filtered or unexported fields */} )
var ( // ErrUnreachable is a call the store did not answer. ErrUnreachable = errors.New("could not reach the store") // ErrRefused is a write, delete or listing the store would not allow. ErrRefused = errors.New("the store refused") // ErrUnknown is a conditional write whose answer was lost: it may or // may not have been written. ErrUnknown = errors.New("the store's answer was lost") // ErrName is a name no store takes. ErrName = errors.New("not a name a store can hold") // ErrNothing is a copy of a name that holds nothing. ErrNothing = errors.New("nothing is there to copy") )
Functions ¶
func Above ¶ added in v0.17.0
Above gives a location and each path above it, nearest first, ending with "/".
func Certificate ¶ added in v0.50.0
func Certificate(key ed25519.PrivateKey) (tls.Certificate, error)
Certificate is what an end of a served directory's wire shows of itself as a connection is made: its identity key and nothing else. Whoever shows it is known to hold the key's other half.
func CheckLocation ¶ added in v0.17.0
CheckLocation says whether a text can be a location: "/", or "/" then parts, each as CheckLocationPart has it and none holding "*", which makes a pattern.
func CheckLocationPart ¶ added in v0.23.0
CheckLocationPart says whether a text can be one part of a location or of a pattern of locations: not empty, ".", ".." or "+", and holding no "#", which separates a key from its location, slash, backslash or control character.
func CheckPart ¶
CheckPart says whether part can be one part of a name: not empty, not starting with a dot, and holding no slash.
func CheckPrefix ¶ added in v0.48.0
CheckPrefix says whether a text can be a tree's prefix: a location, and not "/", where the secrets and values every tree uses are set.
func ChildRun ¶ added in v0.50.0
ChildRun makes the name of a run below another. It follows from what asked for it, so that asking twice names one child.
func DirectoryAt ¶ added in v0.39.0
DirectoryAt gives the directory a directory's address names: a path, file://… or ~/…, made absolute.
func Each ¶ added in v0.9.0
Each does n things side by side, at most limit at a time, and gives the first error. Nothing more is begun once one has failed or the context has ended. One of them may itself do things side by side: what bounds the requests is a store from Bounded.
func Emit ¶
Emit is the name of an emit entry of a job: under the job's number in the run, never its name, since every client lists every record.
func EmitOf ¶ added in v0.21.0
EmitOf reads the job's number and the entry's number out of the name of an emit entry of a run.
func FinishedHead ¶
func House ¶
House is the name the controller's own wake is under, where an run's name would be: the wake for its hourly housekeeping.
func IsReceiptBlob ¶ added in v0.50.0
IsReceiptBlob says whether a name is that of a receipt's blob.
func JobMessage ¶
JobMessage is the name a job has in its runner's inbox and among its marks: fixed by its run and its name.
func JobSubmit ¶ added in v0.48.0
JobSubmit names the message that carries a command a job asked for: the time the step was taken, as a client's message is named, so that the submits of one tree sort in the order they were made, and then the step that asked.
func Key ¶ added in v0.12.0
Key is the name of a key's file among a location's. A key is any text, so the name holds its hash and never the key itself. A singleton's is the empty key.
func LinkMessage ¶
LinkMessage is the name of a message the controller sends itself for one run on behalf of another: fixed by the step that asked for it, and sorting in the order that run's steps asked.
func LocationBlob ¶ added in v0.17.0
func LocationBlobs ¶ added in v0.17.0
func LocationDir ¶ added in v0.17.0
LocationDir is where the entries of one location are: under "+" after its path, and "+" is never a part of a location, so no location's entries are a path above another's. The entries of "/" are under locations/+.
func LocationFile ¶ added in v0.17.0
func MessageOf ¶ added in v0.50.0
MessageOf reads the sender and the message out of the name of a message in a party's inbox.
func MessageTime ¶ added in v0.50.0
MessageTime reads the time a message's name begins with, as Next and JobSubmit write it.
func Names ¶ added in v0.9.0
Names gives the names of a listing, in its order, for a caller that needs no marks: names, err := Names(s.List(ctx, under, 0)).
func ParseLocation ¶ added in v0.17.0
ParseLocation reads the location out of the name of one of its entries, and what follows the location's "+".
func ParseStamp ¶ added in v0.50.0
ParseStamp reads a time Stamp wrote.
func Policy ¶
Policy prints the policy that limits a party's key for a bucket to its row of the table. bucket is the bucket's name and prefix the path the store's address gives after it. The policy is written to be attached to the party's key; set on the bucket itself, each statement needs that key as its principal as well.
Every write a limited party may make is allowed only when the request carries If-None-Match, which is what makes it only-if-new. The steps of a large upload that put nothing under a name are allowed without it, as is giving such an upload up. Listing is allowed only under the paths the party may list. Each name in also is an object in a bucket of its own that the party reads beside its row.
Amazon S3 enforces all of this. A service that takes the same requests but does not know the condition key s3:if-none-match cannot hold a party to only-if-new, and so cannot enforce the table whatever else it does.
A policy cannot say "any one part of a name", so where the table has any one part the policy has any path. A limited party can therefore add names deeper than the layout draws; it still can never replace or remove one.
func PolicyFor ¶
PolicyFor prints the policy for a party of the bucket an address names. Where kept is the address of another bucket, the policy lets the party read the object of that name there as well.
func Receipt ¶
Receipt is the name of the controller's answer to a client's message: in a directory of the message's own name.
func ReceiptBlob ¶ added in v0.17.0
ReceiptBlob is the name of a blob a call's result names.
func ReceiptBlobs ¶ added in v0.17.0
ReceiptBlobs is where the blobs a call's result names are.
func ReceiptMessage ¶ added in v0.17.0
ReceiptMessage reads the message out of the name of a receipt, a result or a receipt's blob.
func Result ¶ added in v0.17.0
Result is the name of what became of the run a client called in a tree it does not own, beside the call's receipt.
func RootRun ¶ added in v0.50.0
RootRun makes the name of a root run that the controller starts for a client, as a submit starts a singleton. It follows from what asked for it, so that asking twice names one run.
func RunningHead ¶
func ServedListener ¶
ServedListener takes the connections to a served directory: the controller proves its key to each with its certificate, and each has to prove a key of its own. Whose key that is the server asks at every request. No connection is taken up again from an earlier one, so nothing of a connection outlives it.
func Source ¶ added in v0.48.0
Source is where a tree's files are kept, at its prefix, and SourceBlob the name of one of them.
func SourceBlob ¶ added in v0.48.0
func Step ¶
Step is the name of a step entry. Numbers are written so that names sort in number order.
func Taken ¶
Taken is the name of the mark a runner leaves for a job it has taken. The name carries the job's due time, so the marks whose time has passed are found by listing alone.
func Unreported ¶ added in v0.37.0
Unreported says why the operating system does not report to this process what other processes write into a directory store, where a wait on the store asked it to and it refused. Any other store gives nil.
func Uploads ¶ added in v0.17.0
Uploads is where the files every client sends with its messages are.
func WriteForward ¶ added in v0.50.0
func WriteForward(ctx context.Context, s Store, name string, value []byte, keep func(there []byte) (bool, error)) (bool, error)
WriteForward writes value under name only forward: only-if-new where nothing is there, and only-if-unchanged where keep gives false for the value there. Where keep gives true, the value there stays as it is. Where another value is written between the read and the write, it reads again and asks keep again. It says whether nothing was there and it wrote value.
Types ¶
type AddressKind ¶ added in v0.50.0
type AddressKind int
AddressKind is the kind of store an address names.
const ( // DirectoryAddress is a directory on this computer: a path, file://… // or ~/…. DirectoryAddress AddressKind = iota // ServedAddress is a directory another computer serves: corbie://host:port. ServedAddress // BucketAddress is a bucket: s3://…. BucketAddress // MemoryAddress is a new store in memory: memory:. MemoryAddress )
func KindOf ¶ added in v0.50.0
func KindOf(address string) AddressKind
KindOf gives the kind of store an address names. "" counts as a directory, which Open refuses.
type How ¶
type How struct {
// contains filtered or unexported fields
}
How is one of the three ways of writing.
func OnlyIfUnchanged ¶
OnlyIfUnchanged writes, or deletes, only if the value is still the one that was read with mark.
type Listed ¶ added in v0.9.0
A Listed is one name a listing gives, with the mark a read of it gives: a value that has not changed since it was read is listed with the mark it was read with.
type Mark ¶
type Mark string
A Mark is what a read saw of a value, for a later only-if-unchanged.
const None Mark = ""
None is the mark of a name that holds nothing.
type Memory ¶
type Memory struct {
// Note, when set, is told of everything done to the store. What a party
// was refused was not done, and is not told.
Note func(Op)
// contains filtered or unexported fields
}
Memory is a store held in memory, for `corbie test` and Corbie's own tests. Each party opens it with As and is held to its row of the table, as a bucket would hold it.
type Op ¶
type Op struct {
Party Party
Act Act
Name string
How How
Value []byte // what was written, or read
Done bool // false for "not there", "already there" or "changed"
}
An Op is one thing a party did to a memory store.
type Party ¶
A Party is one row of the table of who may read and write what. Controller is the controller whose area a runner, a client or a viewer works in.
type Proof ¶
type Proof struct {
Party string
Cert tls.Certificate
Controller ed25519.PublicKey
}
Proof is what a party proves to a served directory: its name and certificate, and the key of the controller whose computer serves the directory, which that computer proves. Its zero value proves nothing.
type Sender ¶
type Sender struct {
// contains filtered or unexported fields
}
A Sender names one sender's messages so that they sort in the order they were sent, also when two are sent in the same instant or the clock steps back.
type Server ¶
type Server struct {
// Directory is the directory served.
Directory Store
// Who says which party a name is and which key is its own. A name that
// is no party of the controller's has no key.
Who func(ctx context.Context, name string) (Party, ed25519.PublicKey, error)
// Failed is told of what went wrong at this end. A party is told only
// that something did: the error itself can name this computer's paths.
Failed func(err error)
// Timeout is how long a party may send nothing of a value it is sending.
// None is no limit.
Timeout time.Duration
// contains filtered or unexported fields
}
A Server serves a directory to the parties of one controller.
type Store ¶
type Store interface {
// Read gives the value under name and the mark to write it back
// only-if-unchanged. A name that holds nothing, or that this party may
// not read, gives the mark None.
Read(ctx context.Context, name string) ([]byte, Mark, error)
// ReadPart gives up to length bytes of the value under name starting at
// from: fewer where the value ends first, none where it is not there.
ReadPart(ctx context.Context, name string, from, length int64) ([]byte, error)
// Write reads a value and writes it in the way how says, and says
// whether it did. The value is under its name only once all of it is
// in. A bucket, a directory and a served directory write a long value
// as it is read, and never hold it whole.
Write(ctx context.Context, name string, value io.Reader, how How) (bool, error)
// Copy puts the value under from under to as well, only-if-new, without
// its bytes passing through the caller.
Copy(ctx context.Context, from, to string) (bool, error)
// Delete removes the value under name: whatever is there (Overwrite) or
// only-if-unchanged. Deleting a name that holds nothing is done.
Delete(ctx context.Context, name string, how How) (bool, error)
// List gives the names under the path, in the order names sort, each
// with the mark a read of it gives: every name where most is 0, and
// otherwise the first most of them, no more than a thousand. The first
// names cost one look, however many names there are: the due wakes are
// read this way, soonest first.
List(ctx context.Context, under string, most int) ([]Listed, error)
// Notice gives a channel that is sent to when this process writes or
// deletes a name under the path, and a func that ends it. A directory
// sends to it as well when another process on the computer writes or
// deletes a message in an inbox or a running head under the path.
Notice(under string) (<-chan struct{}, func())
}
A Store holds named values. Every call concerns one name and nothing is held between calls.
"Not there", "already there" and "changed" are answers, never errors: a read gives the mark None, and a write or delete gives false. An error means the store could not be reached or refused the call.