cells

package
v2.0.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2020 License: AGPL-3.0 Imports: 39 Imported by: 0

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.

  • Copyright (c) 2019. Abstrium SAS <team (at) pydio.com>

  • This file is part of Pydio Cells. *

  • Pydio Cells is free software: you can redistribute it and/or modify

  • it under the terms of the GNU Affero General Public License as published by

  • the Free Software Foundation, either version 3 of the License, or

  • (at your option) any later version. *

  • Pydio Cells is distributed in the hope that it will be useful,

  • but WITHOUT ANY WARRANTY; without even the implied warranty of

  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

  • GNU Affero General Public License for more details. *

  • You should have received a copy of the GNU Affero General Public License

  • along with Pydio Cells. If not, see <http://www.gnu.org/licenses/>. *

  • The latest code can be found at <https://pydio.com>.

  • Copyright (c) 2019. Abstrium SAS <team (at) pydio.com>

  • This file is part of Pydio Cells. *

  • Pydio Cells is free software: you can redistribute it and/or modify

  • it under the terms of the GNU Affero General Public License as published by

  • the Free Software Foundation, either version 3 of the License, or

  • (at your option) any later version. *

  • Pydio Cells is distributed in the hope that it will be useful,

  • but WITHOUT ANY WARRANTY; without even the implied warranty of

  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

  • GNU Affero General Public License for more details. *

  • You should have received a copy of the GNU Affero General Public License

  • along with Pydio Cells. If not, see <http://www.gnu.org/licenses/>. *

  • The latest code can be found at <https://pydio.com>.

Index

Constants

This section is empty.

Variables

View Source
var (
	RemoteCellsServiceName = "pydio.gateway.grpc"
)

Functions

This section is empty.

Types

type DynamicRegistry

type DynamicRegistry struct {
	Micro registry.Registry
	// contains filtered or unexported fields
}

DynamicRegistry is an implementation of a Micro Registry that automatically detect the target GRPC port from the discovery endpoint of the target server.

func NewDynamicRegistry

func NewDynamicRegistry(config *sdk.SdkConfig) *DynamicRegistry

NewDynamicRegistry creates a new DynamicRegistry from a standard SdkConfig

func (*DynamicRegistry) Refresh

func (d *DynamicRegistry) Refresh() error

Refresh deregisters all services and tries to detect service

type Local

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

Local directly connects to a Cells server running in the same network, by connecting to the local NATS registry

func NewLocal

func NewLocal(root string, options Options) *Local

NewLocal creates a new instance of a Local endpoint

func (*Local) ComputeChecksum

func (c *Local) ComputeChecksum(node *tree.Node) error

ComputeChecksum is not implemented

func (*Local) CreateNode

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

CreateNode is used for creating folders only

func (*Local) DeleteNode

func (c *Local) 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 (*Local) GetCachedBranches

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

GetCachedBranches implements CachedBranchProvider by loading branches in a MemDB

func (*Local) GetEndpointInfo

func (l *Local) GetEndpointInfo() model.EndpointInfo

GetEndpointInfo returns info about this endpoint

func (*Local) GetReaderOn

func (c *Local) GetReaderOn(p string) (out io.ReadCloser, err error)

GetReaderOn retrieves an io.ReadCloser from the S3 Get operation

func (*Local) GetWriterOn

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

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

func (*Local) LoadNode

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

LoadNode forwards call to cli.ReadNode

func (*Local) MoveNode

func (c *Local) 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 (*Local) PatchUpdateSnapshot

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

PatchUpdateSnapshot does nothing

func (*Local) SetUpdateSnapshot

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

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

func (*Local) Walk

func (c *Local) Walk(walknFc 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 (*Local) Watch

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

Watch uses a GRPC connection to listen to events from the Grpc Gateway (wired to the 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 Options

type Options struct {
	model.EndpointOptions
	// If router is started in an independent process, call basic initialization to connect to registry.
	LocalInitRegistry bool
	// If a sync is connecting two endpoint of a same server, we have to make sure to avoid Uuid collision
	RenewFolderUuids bool
}

type RegistryRefreshClient

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

RegistryRefreshClient is an implementation of a Micro Client that tries to refresh the registry if a streamer connection is broken (GRPC port may change accross server restart).

func (*RegistryRefreshClient) Call

func (r *RegistryRefreshClient) Call(ctx context.Context, req client.Request, rsp interface{}, opts ...client.CallOption) error

func (*RegistryRefreshClient) CallRemote

func (r *RegistryRefreshClient) CallRemote(ctx context.Context, addr string, req client.Request, rsp interface{}, opts ...client.CallOption) error

func (*RegistryRefreshClient) Init

func (r *RegistryRefreshClient) Init(o ...client.Option) error

func (*RegistryRefreshClient) NewJsonRequest

func (r *RegistryRefreshClient) NewJsonRequest(service, method string, req interface{}, reqOpts ...client.RequestOption) client.Request

func (*RegistryRefreshClient) NewProtoRequest

func (r *RegistryRefreshClient) NewProtoRequest(service, method string, req interface{}, reqOpts ...client.RequestOption) client.Request

func (*RegistryRefreshClient) NewPublication

func (r *RegistryRefreshClient) NewPublication(topic string, msg interface{}) client.Publication

func (*RegistryRefreshClient) NewRequest

func (r *RegistryRefreshClient) NewRequest(service, method string, req interface{}, reqOpts ...client.RequestOption) client.Request

func (*RegistryRefreshClient) Options

func (r *RegistryRefreshClient) Options() client.Options

func (*RegistryRefreshClient) Publish

func (*RegistryRefreshClient) Stream

func (*RegistryRefreshClient) StreamRemote

func (r *RegistryRefreshClient) StreamRemote(ctx context.Context, addr string, req client.Request, opts ...client.CallOption) (client.Streamer, error)

func (*RegistryRefreshClient) String

func (r *RegistryRefreshClient) String() string

type Remote

type Remote struct {
	// 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) ComputeChecksum

func (c *Remote) ComputeChecksum(node *tree.Node) error

ComputeChecksum is not implemented

func (*Remote) CreateNode

func (c *Remote) CreateNode(ctx context.Context, node *tree.Node, 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) DeleteNode

func (c *Remote) 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 (*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) GetCachedBranches

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

GetCachedBranches implements CachedBranchProvider by loading branches in a MemDB

func (*Remote) GetEndpointInfo

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

GetEndpointInfo returns Endpoint information in standard format.

func (*Remote) GetReaderOn

func (c *Remote) GetReaderOn(p string) (out io.ReadCloser, err error)

GetReaderOn retrieves an io.ReadCloser from the S3 Get operation

func (*Remote) GetWriterOn

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

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

func (*Remote) LoadNode

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

LoadNode forwards call to cli.ReadNode

func (*Remote) MoveNode

func (c *Remote) 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 (*Remote) PatchUpdateSnapshot

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

PatchUpdateSnapshot does nothing

func (*Remote) RefreshRemoteConfig

func (c *Remote) RefreshRemoteConfig(config RemoteConfig)

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

func (*Remote) SetUpdateSnapshot

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

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

func (*Remote) StartSession

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

StartSession starts an indexation session.

func (*Remote) Walk

func (c *Remote) Walk(walknFc 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 (*Remote) Watch

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

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

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

Jump to

Keyboard shortcuts

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