Documentation ¶
Index ¶
- Constants
- Variables
- type Archive
- type Archives
- type Bucket
- func (b *Bucket) GetFileEncryptionKeyForPath(pth string) ([]byte, error)
- func (b *Bucket) GetFileEncryptionKeysForPrefix(pre string) (map[string][]byte, error)
- func (b *Bucket) GetLinkEncryptionKey() []byte
- func (b *Bucket) GetMetadataForPath(pth string, requireKey bool) (md Metadata, at string, ok bool)
- func (b *Bucket) IsPrivate() bool
- func (b *Bucket) RotateFileEncryptionKeysForPrefix(pre string) error
- func (b *Bucket) SetMetadataAtPath(pth string, md Metadata)
- func (b *Bucket) UnsetMetadataWithPrefix(pre string)
- type BucketOption
- type BucketOptions
- type Buckets
- func (b *Buckets) ArchiveStatus(ctx context.Context, key string) (ffs.JobStatus, string, error)
- func (b *Buckets) ArchiveWatch(ctx context.Context, key string, ffsToken string, ch chan<- string) error
- func (b *Buckets) Close() error
- func (b *Buckets) GetSafe(ctx context.Context, dbID thread.ID, key string, buck *Bucket, opts ...Option) error
- func (b *Buckets) IsArchivingEnabled() bool
- func (b *Buckets) New(ctx context.Context, dbID thread.ID, key string, pth path.Path, now time.Time, ...) (*Bucket, error)
- type Collection
- func (c *Collection) Create(ctx context.Context, dbID thread.ID, instance interface{}, opts ...Option) (coredb.InstanceID, error)
- func (c *Collection) Delete(ctx context.Context, dbID thread.ID, id string, opts ...Option) error
- func (c *Collection) Get(ctx context.Context, dbID thread.ID, key string, instance interface{}, ...) error
- func (c *Collection) List(ctx context.Context, dbID thread.ID, query *db.Query, instance interface{}, ...) (interface{}, error)
- func (c *Collection) Save(ctx context.Context, dbID thread.ID, instance interface{}, opts ...Option) error
- func (c *Collection) WriteTxn(ctx context.Context, dbID thread.ID, opts ...Option) (*WriteTxn, error)
- type Deal
- type InboxMessage
- type Mail
- type Metadata
- type Option
- type Options
- type SentboxMessage
- type WriteTxn
Constants ¶
const Version = 1
Variables ¶
var ( // ErrMailboxExists indicates that a mailbox with the same name and owner already exists. ErrMailboxExists = errors.New("mailbox already exists") )
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket struct { Key string `json:"_id"` Owner string `json:"owner"` Name string `json:"name"` Version int `json:"version"` LinkKey string `json:"key,omitempty"` Path string `json:"path"` Metadata map[string]Metadata `json:"metadata"` Archives Archives `json:"archives"` CreatedAt int64 `json:"created_at"` UpdatedAt int64 `json:"updated_at"` }
Bucket represents the buckets threaddb collection schema.
func (*Bucket) GetFileEncryptionKeyForPath ¶
GetFileEncryptionKeyForPath returns the encryption key for path. Version 0 buckets use the link key for all paths. Version 1 buckets use a different key defined in path metadata.
func (*Bucket) GetFileEncryptionKeysForPrefix ¶
GetFileEncryptionKeysForPrefix returns a map of keys for every path under prefix.
func (*Bucket) GetLinkEncryptionKey ¶
GetLinkEncryptionKey returns the bucket encryption key as bytes if present. Version 0 buckets use the link key for all files and folders. Version 1 buckets only use the link for folders.
func (*Bucket) GetMetadataForPath ¶
GetMetadataForPath returns metadata for path. The returned metadata could be from an exact path match or the nearest parent, i.e., path was added as part of a folder. If requireKey is true, metadata w/o a key is ignored and the search continues toward root.
func (*Bucket) RotateFileEncryptionKeysForPrefix ¶
RotateFileEncryptionKeysForPrefix re-generates existing metadata keys for every path under prefix.
func (*Bucket) SetMetadataAtPath ¶
SetMetadataAtPath create new or merges existing metadata at path.
func (*Bucket) UnsetMetadataWithPrefix ¶
UnsetMetadataWithPrefix removes metadata with the path prefix.
type BucketOption ¶
type BucketOption func(*BucketOptions)
BucketOption holds a bucket option.
func WithNewBucketKey ¶
func WithNewBucketKey(k []byte) BucketOption
WithNewBucketKey sets the bucket encryption key.
func WithNewBucketName ¶
func WithNewBucketName(n string) BucketOption
WithNewBucketName specifies a name for a bucket. Note: This is only valid when creating a new bucket.
func WithNewBucketToken ¶
func WithNewBucketToken(t thread.Token) BucketOption
WithNewBucketToken sets the threaddb token.
type BucketOptions ¶
BucketOptions defines options for interacting with buckets.
type Buckets ¶
type Buckets struct { Collection // contains filtered or unexported fields }
Buckets is a wrapper around a threaddb collection that performs object storage on IPFS and Filecoin.
func NewBuckets ¶
NewBuckets returns a new buckets collection mananger.
func (*Buckets) ArchiveStatus ¶
ArchiveStatus returns the last known archive status on Powergate. If the return status is Failed, an extra string with the error message is provided.
func (*Buckets) ArchiveWatch ¶
func (b *Buckets) ArchiveWatch(ctx context.Context, key string, ffsToken string, ch chan<- string) error
ArchiveWatch allows to have the last log execution for the last archive, plus realtime human-friendly log output of how the current archive is executing. If the last archive is already done, it will simply return the log history and close the channel.
func (*Buckets) GetSafe ¶
func (b *Buckets) GetSafe(ctx context.Context, dbID thread.ID, key string, buck *Bucket, opts ...Option) error
GetSafe gets a bucket instance and inflates any values that are nil due to schema updates.
func (*Buckets) IsArchivingEnabled ¶
IsArchivingEnabled returns whether or not Powergate archiving is enabled.
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection wraps a ThreadDB collection with some convenience methods.
func (*Collection) Create ¶
func (c *Collection) Create(ctx context.Context, dbID thread.ID, instance interface{}, opts ...Option) (coredb.InstanceID, error)
Create a collection instance.
func (*Collection) Get ¶
func (c *Collection) Get(ctx context.Context, dbID thread.ID, key string, instance interface{}, opts ...Option) error
Get a collection instance.
func (*Collection) List ¶
func (c *Collection) List(ctx context.Context, dbID thread.ID, query *db.Query, instance interface{}, opts ...Option) (interface{}, error)
List collection instances.
func (*Collection) Save ¶
func (c *Collection) Save(ctx context.Context, dbID thread.ID, instance interface{}, opts ...Option) error
Save a collection instance.
func (*Collection) WriteTxn ¶
func (c *Collection) WriteTxn(ctx context.Context, dbID thread.ID, opts ...Option) (*WriteTxn, error)
WriteTxn returns a write transaction in the collection. Call WriteTxn.End to commit the transaction. Using a defer statement and a named err param is the usual pattern:
func MyFunc() (err error) { defer func() { if e := txn.End(err); err == nil { err = e } }() ... if err = txn.Save(...); err != nil { return nil, err } ... if err = txn.Save(...); err != nil { return nil, err } ... }
See WriteTxn.End for more.
type InboxMessage ¶
type InboxMessage struct { ID string `json:"_id"` From string `json:"from"` To string `json:"to"` Body string `json:"body"` Signature string `json:"signature"` CreatedAt int64 `json:"created_at"` ReadAt int64 `json:"read_at"` }
InboxMessage represents the inbox threaddb collection schema.
type Mail ¶
type Mail struct { Inbox Collection Sentbox Collection // contains filtered or unexported fields }
Mail is a wrapper around a threaddb collection for sending mail between users.
type Metadata ¶
type Metadata struct { Key string `json:"key,omitempty"` Roles map[string]buckets.Role `json:"roles"` UpdatedAt int64 `json:"updated_at"` }
Metadata contains metadata about a bucket item (a file or folder).
func NewDefaultMetadata ¶
NewDefaultMetadata returns the default metadata for a path.
func (*Metadata) SetFileEncryptionKey ¶
SetFileEncryptionKey sets the file encryption key.
type SentboxMessage ¶
type SentboxMessage struct { ID string `json:"_id"` From string `json:"from"` To string `json:"to"` Body string `json:"body"` Signature string `json:"signature"` CreatedAt int64 `json:"created_at"` }
SentboxMessage represents the sentbox threaddb collection schema.
type WriteTxn ¶
type WriteTxn struct {
// contains filtered or unexported fields
}
WriteTxn wraps a write transaction in a collection.
func (*WriteTxn) End ¶
End ends the underlying transaction. A non-nil err results in the transaction being discarded before it's ended.