cells

package
v4.3.1-rc3 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: AGPL-3.0 Imports: 33 Imported by: 1

Documentation

Overview

Package cells provides endpoints for speaking either with a local server using a views.Router (and connecting to the local NATS registry), or a remote Cells server using a GRPC gateway client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Abstract

type Abstract struct {
	sync.Mutex
	Factory clientProviderFactory
	Source  model.PathSyncSource

	ClientUUID   string
	Root         string
	Options      Options
	RecentMkDirs []tree.N
	GlobalCtx    context.Context
	// contains filtered or unexported fields
}

func (*Abstract) ComputeChecksum

func (c *Abstract) ComputeChecksum(ctx context.Context, node tree.N) error

ComputeChecksum is not implemented

func (*Abstract) CreateNode

func (c *Abstract) CreateNode(ctx context.Context, node tree.N, updateIfExists bool) (err error)

CreateNode is used for creating folders only

func (*Abstract) DeleteNode

func (c *Abstract) DeleteNode(ctx context.Context, name string) (err error)

DeleteNode forwards call to the grpc gateway. For folders, the recursive deletion will happen on the gateway side. It may take some time, thus a request timeout of 5 minutes.

func (*Abstract) GetCachedBranches

func (c *Abstract) GetCachedBranches(ctx context.Context, roots ...string) (model.PathSyncSource, error)

GetCachedBranches implements CachedBranchProvider by loading branches in a MemDB

func (*Abstract) GetReaderOn

func (c *Abstract) GetReaderOn(ctx context.Context, p string) (out io.ReadCloser, err error)

GetReaderOn retrieves an io.ReadCloser from the S3 Get operation

func (*Abstract) GetWriterOn

func (c *Abstract) GetWriterOn(cancel context.Context, p string, targetSize int64) (out io.WriteCloser, writeDone chan bool, writeErr chan error, err error)

GetWriterOn retrieves a WriteCloser wired to the S3 gateway to PUT a file.

func (*Abstract) LoadNode

func (c *Abstract) LoadNode(ctx context.Context, path string, extendedStats ...bool) (node tree.N, err error)

LoadNode forwards call to cli.ReadNode

func (*Abstract) MoveNode

func (c *Abstract) MoveNode(ct context.Context, oldPath string, newPath string) (err error)

MoveNode renames a file or folder and *blocks* until the node has been properly moved (sync)

func (*Abstract) PatchUpdateSnapshot

func (c *Abstract) PatchUpdateSnapshot(ctx context.Context, patch interface{})

PatchUpdateSnapshot does nothing

func (*Abstract) SetUpdateSnapshot

func (c *Abstract) SetUpdateSnapshot(target model.PathSyncTarget)

SetUpdateSnapshot registers a snapshot to be updated when events are received from server

func (*Abstract) Walk

func (c *Abstract) Walk(ctx context.Context, walkFunc model.WalkNodesFunc, root string, recursive bool) (err error)

Walk uses cli.ListNodes() to browse nodes starting from a root (recursively or not). Temporary nodes are ignored. Workspaces nodes are ignored if they don't have the WorkspaceSyncable flag in their Metadata

func (*Abstract) Watch

func (c *Abstract) Watch(recursivePath string) (*model.WatchObject, error)

Watch uses a GRPC connection to listen to events from the Grpc Gateway (wired to the Tree Service via a Router).

type NoopWriter

type NoopWriter struct{}

NoopWriter is a simple writer for ignoring contents

func (*NoopWriter) Close

func (nw *NoopWriter) Close() error

func (*NoopWriter) Write

func (nw *NoopWriter) Write(p []byte) (n int, err error)

type ObjectsClient

type ObjectsClient interface {
	GetObject(ctx context.Context, node *tree.Node, requestData *models.GetRequestData) (io.ReadCloser, error)
	PutObject(ctx context.Context, node *tree.Node, reader io.Reader, requestData *models.PutRequestData) (models.ObjectInfo, error)
	CopyObject(ctx context.Context, from *tree.Node, to *tree.Node, requestData *models.CopyRequestData) (models.ObjectInfo, error)
}

type Options

type Options struct {
	model.EndpointOptions
	// If router is started in an independent process, call basic initialization to connect to registry.
	LocalInitRegistry bool
	// When starting endpoint within a known runtime, set runtime context (e.g. scheduler task)
	LocalRuntimeContext context.Context
	// If a sync is connecting two endpoint of a same server, we have to make sure to avoid Uuid collision
	RenewFolderUuids bool
}

type Remote

type Remote struct {
	Abstract
	// contains filtered or unexported fields
}

Remote connect to a remove Cells server using the GRPC gateway.

func NewRemote

func NewRemote(config RemoteConfig, root string, options Options) *Remote

NewRemote creates a new Remote Endpoint

func (*Remote) BulkLoadNodes

func (c *Remote) BulkLoadNodes(ctx context.Context, nodes map[string]string) (map[string]interface{}, error)

BulkLoadNodes streams ReadNode requests from server

func (*Remote) CreateNode

func (c *Remote) CreateNode(ctx context.Context, node tree.N, updateIfExists bool) (err error)

CreateNode creates folder, eventually resetting their UUID if the options RenewFolderUuids is set. If an indexation session is started, it stacks all Creates in memory and perform them only at Flush.

func (*Remote) FinishSession

func (c *Remote) FinishSession(ctx context.Context, sessionUuid string) error

FinishSession flushes the session and closes it.

func (*Remote) FlushSession

func (c *Remote) FlushSession(ctx context.Context, sessionUuid string) error

FlushSession sends all creates as a stream to the target server

func (*Remote) GetEndpointInfo

func (c *Remote) GetEndpointInfo() model.EndpointInfo

GetEndpointInfo returns Endpoint information in standard format.

func (*Remote) RefreshRemoteConfig

func (c *Remote) RefreshRemoteConfig(config RemoteConfig)

RefreshRemoteConfig is used to refresh ID Token / Refresh Token from outside

func (*Remote) StartSession

func (c *Remote) StartSession(ctx context.Context, rootNode tree.N, silent bool) (string, error)

StartSession starts an indexation session.

type RemoteConfig

type RemoteConfig struct {
	// Url stores domain name or IP & port to the server.
	Url string `json:"url"`
	// OIDC GrantPassword Flow
	ClientKey    string `json:"clientKey"`
	ClientSecret string `json:"clientSecret"`
	User         string `json:"user"`
	Password     string `json:"password"`
	// OIDC Code Flow
	IdToken      string `json:"id_token"`
	RefreshToken string `json:"refresh_token"`
	ExpiresAt    int    `json:"expires_at"`
	// SkipVerify tells the transport to ignore expired or self-signed TLS certificates
	SkipVerify    bool              `json:"skipVerify"`
	CustomHeaders map[string]string `json:"-"`
}

RemoteConfig is a dependency-free struct similar to SdkConfig

Directories

Path Synopsis
Package transport provides a ready to use SDK to use the Cells REST API in Go language.
Package transport provides a ready to use SDK to use the Cells REST API in Go language.
mc

Jump to

Keyboard shortcuts

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