Documentation ¶
Index ¶
- Variables
- func IsPathNotFoundErr(err error) bool
- type Bucket
- type Buckets
- func (b *Buckets) Close() error
- func (b *Buckets) Create(ctx context.Context, identity did.Token, opts ...CreateOption) (*Bucket, *Seed, int64, error)
- func (b *Buckets) DB() *dbc.Client
- func (b *Buckets) Get(ctx context.Context, thread core.ID, key string, identity did.Token) (*Bucket, error)
- func (b *Buckets) GetLinks(ctx context.Context, thread core.ID, key string, identity did.Token, ...) (links Links, err error)
- func (b *Buckets) GetLinksForBucket(ctx context.Context, bucket *Bucket, identity did.Token, pth string) (links Links, err error)
- func (b *Buckets) Ipfs() iface.CoreAPI
- func (b *Buckets) IsReadablePath(ctx context.Context, thread core.ID, key string, identity did.Token, ...) (bool, error)
- func (b *Buckets) IsWritablePath(ctx context.Context, thread core.ID, key string, identity did.Token, ...) (bool, error)
- func (b *Buckets) List(ctx context.Context, thread core.ID, identity did.Token) ([]Bucket, error)
- func (b *Buckets) ListIPFSPath(ctx context.Context, pth string) (*PathItem, error)
- func (b *Buckets) ListPath(ctx context.Context, thread core.ID, key string, identity did.Token, ...) (*PathItem, *Bucket, error)
- func (b *Buckets) MovePath(ctx context.Context, thread core.ID, key string, identity did.Token, ...) (int64, *Bucket, error)
- func (b *Buckets) Net() *nc.Client
- func (b *Buckets) NewTxn(thread core.ID, key string, identity did.Token) (*Txn, error)
- func (b *Buckets) PullIPFSPath(ctx context.Context, pth string) (io.ReadCloser, error)
- func (b *Buckets) PullPath(ctx context.Context, thread core.ID, key string, identity did.Token, ...) (io.ReadCloser, error)
- func (b *Buckets) PullPathAccessRoles(ctx context.Context, thread core.ID, key string, identity did.Token, ...) (map[did.DID]collection.Role, error)
- func (b *Buckets) PullPathInfo(ctx context.Context, thread core.ID, key string, identity did.Token, ...) (map[string]interface{}, error)
- func (b *Buckets) PushPath(ctx context.Context, thread core.ID, key string, identity did.Token, ...) (*PushPathsResult, error)
- func (b *Buckets) PushPathAccessRoles(ctx context.Context, thread core.ID, key string, identity did.Token, ...) (int64, *Bucket, error)
- func (b *Buckets) PushPathInfo(ctx context.Context, thread core.ID, key string, identity did.Token, ...) (*Bucket, error)
- func (b *Buckets) PushPaths(ctx context.Context, thread core.ID, key string, identity did.Token, ...) (chan<- PushPathsInput, <-chan PushPathsResult, <-chan error)
- func (b *Buckets) Remove(ctx context.Context, thread core.ID, key string, identity did.Token) (int64, error)
- func (b *Buckets) RemovePath(ctx context.Context, thread core.ID, key string, identity did.Token, ...) (int64, *Bucket, error)
- func (b *Buckets) SetPath(ctx context.Context, thread core.ID, key string, identity did.Token, ...) (int64, *Bucket, error)
- type CreateOption
- type CreateOptions
- type Links
- type Option
- type Options
- type PathItem
- type PushPathsInput
- type PushPathsResult
- type Seed
- type Txn
- func (t *Txn) Close() error
- func (t *Txn) MovePath(ctx context.Context, root path.Resolved, fpth, tpth string) (int64, *Bucket, error)
- func (t *Txn) PushPath(ctx context.Context, root path.Resolved, input PushPathsInput) (*PushPathsResult, error)
- func (t *Txn) PushPathAccessRoles(ctx context.Context, root path.Resolved, pth string, ...) (int64, *Bucket, error)
- func (t *Txn) PushPathInfo(ctx context.Context, root path.Resolved, pth string, ...) (*Bucket, error)
- func (t *Txn) PushPaths(ctx context.Context, root path.Resolved) (chan<- PushPathsInput, <-chan PushPathsResult, <-chan error)
- func (t *Txn) Remove(ctx context.Context) (int64, error)
- func (t *Txn) RemovePath(ctx context.Context, root path.Resolved, pth string) (int64, *Bucket, error)
- func (t *Txn) SetPath(ctx context.Context, root path.Resolved, pth string, cid c.Cid, ...) (int64, *Bucket, error)
Constants ¶
This section is empty.
Variables ¶
var ( // GatewayURL is used to construct externally facing bucket links. GatewayURL string // ThreadsGatewayURL is used to construct externally facing bucket links. ThreadsGatewayURL string // WWWDomain can be set to specify the domain to use for bucket website hosting, e.g., // if this is set to mydomain.com, buckets can be rendered as a website at the following URL: // https://<bucket_key>.mydomain.com WWWDomain string // ErrNonFastForward is returned when an update in non-fast-forward. ErrNonFastForward = errors.New("update is non-fast-forward") )
Functions ¶
func IsPathNotFoundErr ¶
IsPathNotFoundErr returns whether or not an error indicates a bucket path was not found. This is needed because public and private (encrypted) buckets can return different errors for the same operation.
Types ¶
type Bucket ¶
type Bucket struct { Thread core.ID `json:"thread"` collection.Bucket }
Bucket adds thread ID to collection.Bucket.
type Buckets ¶
type Buckets struct {
// contains filtered or unexported fields
}
Buckets is an object storage library built on Threads, IPFS, and IPNS.
func NewBuckets ¶
func NewBuckets( net *nc.Client, db *dbc.Client, ipfs iface.CoreAPI, ipns *ipns.Manager, dns *dns.Manager, ) (*Buckets, error)
NewBuckets returns a new buckets library.
func (*Buckets) Create ¶
func (b *Buckets) Create( ctx context.Context, identity did.Token, opts ...CreateOption, ) (*Bucket, *Seed, int64, error)
Create a new bucket using identity. See CreateOption for more details.
func (*Buckets) Get ¶
func (b *Buckets) Get(ctx context.Context, thread core.ID, key string, identity did.Token) (*Bucket, error)
Get returns a bucket by thread id and key.
func (*Buckets) GetLinks ¶
func (b *Buckets) GetLinks( ctx context.Context, thread core.ID, key string, identity did.Token, pth string, ) (links Links, err error)
GetLinks returns a Links object containing the bucket thread, IPNS, and WWW links by thread and bucket key.
func (*Buckets) GetLinksForBucket ¶
func (b *Buckets) GetLinksForBucket( ctx context.Context, bucket *Bucket, identity did.Token, pth string, ) (links Links, err error)
GetLinksForBucket returns a Links object containing the bucket thread, IPNS, and WWW links.
func (*Buckets) IsReadablePath ¶
func (b *Buckets) IsReadablePath( ctx context.Context, thread core.ID, key string, identity did.Token, pth string, ) (bool, error)
IsReadablePath returns whether or not a path is readable by an identity.
func (*Buckets) IsWritablePath ¶
func (b *Buckets) IsWritablePath( ctx context.Context, thread core.ID, key string, identity did.Token, pth string, ) (bool, error)
IsWritablePath returns whether or not a path is writable by an identity.
func (*Buckets) ListIPFSPath ¶
ListIPFSPath lists all paths under a path.
func (*Buckets) ListPath ¶
func (b *Buckets) ListPath( ctx context.Context, thread core.ID, key string, identity did.Token, pth string, ) (*PathItem, *Bucket, error)
ListPath lists all paths under a path.
func (*Buckets) MovePath ¶
func (b *Buckets) MovePath( ctx context.Context, thread core.ID, key string, identity did.Token, root path.Resolved, fpth, tpth string, ) (int64, *Bucket, error)
MovePath moves a path to a different location. The destination path does not need to exist. Currently, moving the root path is not possible.
func (*Buckets) PullIPFSPath ¶
PullIPFSPath returns a reader to an IPFS path.
func (*Buckets) PullPath ¶
func (b *Buckets) PullPath( ctx context.Context, thread core.ID, key string, identity did.Token, pth string, ) (io.ReadCloser, error)
PullPath returns a reader to a bucket path.
func (*Buckets) PullPathAccessRoles ¶
func (b *Buckets) PullPathAccessRoles( ctx context.Context, thread core.ID, key string, identity did.Token, pth string, ) (map[did.DID]collection.Role, error)
PullPathAccessRoles pulls access roles for a bucket path.
func (*Buckets) PullPathInfo ¶
func (b *Buckets) PullPathInfo( ctx context.Context, thread core.ID, key string, identity did.Token, pth string, ) (map[string]interface{}, error)
PullPathInfo pulls all info at a path.
func (*Buckets) PushPath ¶
func (b *Buckets) PushPath( ctx context.Context, thread core.ID, key string, identity did.Token, root path.Resolved, input PushPathsInput, ) (*PushPathsResult, error)
PushPath pushes data to a single bucket path.
func (*Buckets) PushPathAccessRoles ¶
func (b *Buckets) PushPathAccessRoles( ctx context.Context, thread core.ID, key string, identity did.Token, root path.Resolved, pth string, roles map[did.DID]collection.Role, ) (int64, *Bucket, error)
PushPathAccessRoles pushes new access roles to bucket paths. Access roles are keyed by did.DID. Roles are inherited by path children.
func (*Buckets) PushPathInfo ¶
func (b *Buckets) PushPathInfo( ctx context.Context, thread core.ID, key string, identity did.Token, root path.Resolved, pth string, info map[string]interface{}, ) (*Bucket, error)
PushPathInfo pushes arbitrary info/metadata to a path, allowing users to add application specific path metadata.
func (*Buckets) PushPaths ¶
func (b *Buckets) PushPaths( ctx context.Context, thread core.ID, key string, identity did.Token, root path.Resolved, ) (chan<- PushPathsInput, <-chan PushPathsResult, <-chan error)
PushPaths pushes data to one or more bucket paths. The returned channels are used to push one or more PushPathsInput. Each input will result in a PushPathsResult. Use this method to bulk write data to a bucket.
func (*Buckets) Remove ¶
func (b *Buckets) Remove(ctx context.Context, thread core.ID, key string, identity did.Token) (int64, error)
Remove removes an entire bucket, unpinning all data.
type CreateOption ¶
type CreateOption func(*CreateOptions)
func WithCid ¶
func WithCid(cid c.Cid) CreateOption
WithCid indicates that an inited bucket should be boostraped from a UnixFS DAG.
func WithPrivate ¶
func WithPrivate(private bool) CreateOption
WithPrivate specifies that an encryption key will be used for the bucket.
func WithThread ¶
func WithThread(thread core.ID) CreateOption
WithThread specifies a thread for the bucket. A new thread is created by default.
type CreateOptions ¶
CreateOptions are used when creating a new bucket.
type Links ¶
type Links struct { // URL is the thread URL, which maps to a ThreadDB collection instance. URL string `json:"url"` // WWW is the URL at which the bucket will be rendered as a website (requires remote DNS configuration). WWW string `json:"www"` // IPNS is the bucket IPNS address. IPNS string `json:"ipns"` // BPS is the bucket pinning service URL. BPS string `json:"bps"` }
Links wraps links for resolving a bucket with various protocols.
type Option ¶
type Option func(*Options)
func WithFastForwardOnly ¶
WithFastForwardOnly instructs the remote to reject non-fast-forward updates by comparing root with the remote.
func WithProgress ¶
WithProgress writes progress updates to the given channel.
type PathItem ¶
type PathItem struct { Cid string `json:"cid"` Name string `json:"name"` Path string `json:"path"` Size int64 `json:"size"` IsDir bool `json:"is_dir"` Items []PathItem `json:"items"` ItemsCount int32 `json:"items_count"` Metadata collection.Metadata `json:"metadata"` }
PathItem describes a file or directory in a bucket.
type PushPathsInput ¶
type PushPathsInput struct { // Path is a bucket relative path at which to insert data. Path string // Reader from which to write data into Path. Reader io.Reader // Chunk should be used to add chunked data when a plain io.Reader is not available. Chunk []byte // Meta is optional metadata the will be persisted under Path. Meta map[string]interface{} }
PushPathsInput is used to with PushPath and PushPaths to specify a reader or chunked data to push to a path.
type PushPathsResult ¶
PushPathsResult contains the result of a single push result from PuthPath or PushPaths.
type Txn ¶
type Txn struct {
// contains filtered or unexported fields
}
Txn allows for holding a bucket lock while performing multiple write operations.
func (*Txn) MovePath ¶
func (t *Txn) MovePath( ctx context.Context, root path.Resolved, fpth, tpth string, ) (int64, *Bucket, error)
MovePath is Txn based MovePath.
func (*Txn) PushPath ¶
func (t *Txn) PushPath( ctx context.Context, root path.Resolved, input PushPathsInput, ) (*PushPathsResult, error)
PushPath is Txn based PushPath.
func (*Txn) PushPathAccessRoles ¶
func (t *Txn) PushPathAccessRoles( ctx context.Context, root path.Resolved, pth string, roles map[did.DID]collection.Role, ) (int64, *Bucket, error)
PushPathAccessRoles is Txn based PushPathInfo.
func (*Txn) PushPathInfo ¶
func (t *Txn) PushPathInfo( ctx context.Context, root path.Resolved, pth string, info map[string]interface{}, ) (*Bucket, error)
PushPathInfo is Txn based PushPathInfo.
func (*Txn) PushPaths ¶
func (t *Txn) PushPaths( ctx context.Context, root path.Resolved, ) (chan<- PushPathsInput, <-chan PushPathsResult, <-chan error)
PushPaths is Txn based PushPaths.