service

package
v1.0.0-alpha1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 23 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package service holds the data vertical's business rules: registered datasets, the storages they live on and the virtual datasets assembled out of them, all reached through ownership and sharing rules rather than through platform roles.

The rule itself lives in api/sharing/service, which every vertical shares. What is here is the part only this vertical can answer: which record an id names, who owns it, and which shares apply to it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDataProductSharingService

func NewDataProductSharingService(
	db *gorm.DB,
	products *repository.DataProductRepository,
	sharing *sharingrepo.Repository,
	groups *iamrepo.GroupRepository,
	users *iamrepo.UserRepository,
	members *iamrepo.GroupMemberRepository,
) *sharingsvc.Service

NewDataProductSharingService returns the sharing service for data products.

func NewSCPDataStorageSharingService

func NewSCPDataStorageSharingService(
	db *gorm.DB,
	storages *repository.SCPDataStorageRepository,
	sharing *sharingrepo.Repository,
	groups *iamrepo.GroupRepository,
	users *iamrepo.UserRepository,
	members *iamrepo.GroupMemberRepository,
) *sharingsvc.Service

NewSCPDataStorageSharingService returns the sharing service for SCP data storages.

func NewVirtualDataDirectorySharingService

func NewVirtualDataDirectorySharingService(
	db *gorm.DB,
	directories *repository.VirtualDataDirectoryRepository,
	sharing *sharingrepo.Repository,
	groups *iamrepo.GroupRepository,
	users *iamrepo.UserRepository,
	members *iamrepo.GroupMemberRepository,
) *sharingsvc.Service

NewVirtualDataDirectorySharingService returns the sharing service for virtual data directories.

Types

type DataProductService

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

DataProductService manages registered datasets.

A product belongs to whoever registered it, and everyone else reaches it only through a sharing rule — there is no listing an ordinary caller can use to discover products that were never shared with them.

func NewDataProductService

NewDataProductService returns a data product service.

func (*DataProductService) Create

Create registers a dataset owned by the calling user.

The storage it names must be one the caller can already reach: registering data into a storage nobody shared with them would be a way to have the platform touch a host they have no standing on.

func (*DataProductService) Delete

func (s *DataProductService) Delete(ctx context.Context, id string) error

Delete removes a product and every share of it, for its owner or an admin.

The shares go first and in the same transaction: their foreign keys are RESTRICT, so leaving them would turn an ordinary delete into a constraint violation.

func (*DataProductService) Get

Get returns one product, to anyone holding READ on it.

func (*DataProductService) List

List returns every product across every owner. Needs dataproduct:list — it names who holds what data.

func (*DataProductService) ListMine

ListMine returns the caller's own products.

func (*DataProductService) ListSharedWithMe

func (s *DataProductService) ListSharedWithMe(ctx context.Context) ([]dto.DataProductResponse, error)

ListSharedWithMe returns the products other users have shared with the caller, directly or through a group, each carrying what it grants them.

func (*DataProductService) Update

Update changes a product's own fields. It needs WRITE, which a share can confer.

The owner, the provision status and the creation time are left alone: re-deriving the owner from the caller's token would hand the product to whichever admin — or grantee — happened to issue the request.

type DataTransferService

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

func NewDataTransferService

func NewDataTransferService(
	db *gorm.DB,
	products *repository.DataProductRepository,
	sharing *sharingrepo.Repository,
	storages *repository.SCPDataStorageRepository,
	members *iamrepo.GroupMemberRepository,
	transport Transport,
) *DataTransferService

NewDataTransferService returns a transfer service moving bytes through transport.

func (*DataTransferService) Download

func (s *DataTransferService) Download(ctx context.Context, id string) (*Download, error)

Download stages the product's remote file locally and returns a handle to it.

func (*DataTransferService) Upload

Upload writes content to the product's remote path, replacing whatever was there.

type Download

type Download struct {
	FileName string
	Size     int64

	io.ReadCloser
}

Download is the handle a caller streams a product's bytes from.

type Endpoint

type Endpoint struct {
	Host      string
	Port      int
	LoginUser string
	Key       credmodel.SSHCredential
}

Endpoint is the host and account one transfer runs against.

type SCPDataStorageService

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

SCPDataStorageService manages the storages datasets are staged through.

Registering one is self-service: any authenticated caller may declare a storage on a host of their choosing, under an account of their choosing, presenting one of their own SSH credentials, and it belongs to them. Everyone else reaches it through its sharing rules — which is how they stage under a key they do not hold.

func NewSCPDataStorageService

NewSCPDataStorageService returns a storage service.

func (*SCPDataStorageService) Create

Create registers a storage owned by the calling user, on the host it names and under an existing SSH credential.

The owner is taken from the token, so there is no way to register a storage on someone else's behalf.

func (*SCPDataStorageService) Delete

func (s *SCPDataStorageService) Delete(ctx context.Context, id string) error

Delete removes a storage nothing is staged on, together with its shares.

Products are checked first: a product's storage id carries no foreign key — it is qualified by a storage *type* — so nothing at the database level would stop this from orphaning them.

func (*SCPDataStorageService) Get

Get returns one storage, to an admin or to anyone a share reaches.

func (*SCPDataStorageService) List

List returns every storage across every owner. Needs storage:list — it names who stages what where.

func (*SCPDataStorageService) ListMine

ListMine returns the caller's own storages.

func (*SCPDataStorageService) ListSharedWithMe

func (s *SCPDataStorageService) ListSharedWithMe(ctx context.Context) ([]dto.SCPDataStorageResponse, error)

ListSharedWithMe returns the storages other users have shared with the caller, directly or through a group, each carrying what it grants them.

func (*SCPDataStorageService) Update

Update changes a storage, including which host it stages through and which account and key it stages under. It needs WRITE, which a share can confer.

The owner is deliberately left alone: re-deriving it from the caller's token would hand the storage to whichever admin — or grantee — happened to issue the request.

type SCPTransport

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

func NewSCPTransport

func NewSCPTransport(sshContext *ssh.GlobalSSHContext) *SCPTransport

func (*SCPTransport) Download

func (t *SCPTransport) Download(ctx context.Context, ep Endpoint, remotePath, localPath string) error

func (*SCPTransport) MakeDirectory

func (t *SCPTransport) MakeDirectory(ctx context.Context, ep Endpoint, remoteDir string) error

func (*SCPTransport) Upload

func (t *SCPTransport) Upload(ctx context.Context, ep Endpoint, localPath, remotePath string) error

type Transport

type Transport interface {
	Download(ctx context.Context, ep Endpoint, remotePath, localPath string) error
	Upload(ctx context.Context, ep Endpoint, localPath, remotePath string) error
	MakeDirectory(ctx context.Context, ep Endpoint, remoteDir string) error
}

Transport moves a single file between this server and the host an Endpoint names.

type VirtualDataDirectoryService

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

VirtualDataDirectoryService manages the directory nodes of virtual datasets.

A dataset is a tree of references to already-registered products. Creating a node never moves or copies data: it records that a product appears at a place in a tree, which is why placing one needs only READ on the product itself.

func NewVirtualDataDirectoryService

NewVirtualDataDirectoryService returns a virtual data directory service.

func (*VirtualDataDirectoryService) Create

Create adds a directory node.

With no parent it is a new dataset, owned by the caller. With one it is placed inside an existing dataset, which needs WRITE there, and it inherits that dataset's owner rather than belonging to whoever added it — a grantee building out someone else's dataset does not come to own a piece of it.

func (*VirtualDataDirectoryService) Delete

Delete removes a directory and everything under it, for an owner in its lineage or an admin.

Control rather than WRITE: the subtree can hold nodes other people were granted access to, and withdrawing that is the owner's decision.

The directory rows below are cascaded away by the database. Their shares are not — nothing in the sharing table points at a directory — so they are collected and deleted here, in the same transaction, before the subtree they describe is gone.

func (*VirtualDataDirectoryService) Get

Get returns one directory without its contents, to anyone holding READ on it.

func (*VirtualDataDirectoryService) GetContents

GetContents returns one directory with the files and directories directly under it.

One level only. A dataset can be arbitrarily deep, and returning all of it would make the cost of a request a property of someone else's data rather than of the request; callers walk down a level at a time.

func (*VirtualDataDirectoryService) List

List returns every directory node across every dataset. Needs virtualdirectory:list — it names who holds what data.

func (*VirtualDataDirectoryService) ListMine

ListMine returns the roots of the caller's own datasets.

Roots only: every other node is reached by walking down from one of these, and listing them all would bury the datasets under their own contents.

func (*VirtualDataDirectoryService) ListSharedWithMe

ListSharedWithMe returns the directories other users have shared with the caller, directly or through a group, each carrying what it grants them.

The nodes returned are the ones the shares name, which may be interior: a share opens a subtree, and its top is as far up as the grantee can see.

func (*VirtualDataDirectoryService) Update

Update renames a directory, re-points the product it stands for, or moves it.

It needs WRITE on the node. Moving it needs WRITE on the destination too, and is refused if the destination sits inside the subtree being moved. The owner and the creation time are left alone: re-deriving the owner from the caller's token would hand the dataset to whichever grantee happened to issue the request.

type VirtualDataFileService

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

VirtualDataFileService manages the leaves of virtual datasets.

A file carries no owner and no shares of its own: it is reached through the directory it sits under, and everything about who may touch it is decided there.

func (*VirtualDataFileService) Create

Create places a file product into a directory, which needs WRITE there.

func (*VirtualDataFileService) Delete

func (s *VirtualDataFileService) Delete(ctx context.Context, id string) error

Delete removes a file from its dataset, which needs WRITE on the directory holding it. The product it cited stays registered.

WRITE rather than control, unlike deleting a directory: a leaf carries no shares, so removing one withdraws nobody's access.

func (*VirtualDataFileService) Get

Get returns one file, to anyone holding READ on the directory it sits under.

func (*VirtualDataFileService) ListByDirectory

func (s *VirtualDataFileService) ListByDirectory(ctx context.Context, directoryID string) ([]dto.VirtualDataFileResponse, error)

ListByDirectory returns the files directly under one directory, to anyone holding READ on it.

func (*VirtualDataFileService) Update

Update renames a file, re-points the product it stands for, or moves it to another directory.

A move needs WRITE on both ends: taking an entry out of a dataset is a write to the dataset losing it just as much as to the one gaining it.

Jump to

Keyboard shortcuts

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