gateway

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticationDetailsReader added in v0.0.7

type AuthenticationDetailsReader interface {
	// Read reads the authentication details to connect to the instance.
	Read(ctx context.Context, instanceID string) (accessKeyID, secretAccessKey string, err error)
}

AuthenticationDetailsReader defines the port to read auth details to connect to the storage instance.

type Gateway

type Gateway struct {
	Logger *slog.Logger
	// contains filtered or unexported fields
}

func New

func New(
	storageInstancesSelector string,
	storageBucket string,
	serviceRegistryClient ServiceRegistryScanner,
	connectionDetailsReader AuthenticationDetailsReader,
	newStorageConnectionFn StorageConnectionFn,
	logger *slog.Logger,
) (*Gateway, error)

New initializes a Gateway.

func (*Gateway) Read

func (s *Gateway) Read(ctx context.Context, id string) (io.ReadCloser, bool, error)

Read reads the object given its ID.

func (*Gateway) Write

func (s *Gateway) Write(ctx context.Context, id string, reader io.Reader, objectSizeBytes int64) error

Write writes object to the storage.

type ObjectReadWriteFinder

type ObjectReadWriteFinder interface {
	// Read reads the object.
	Read(ctx context.Context, bucketName, objectName string) (io.ReadCloser, bool, error)

	// Write writes the object.
	Write(ctx context.Context, bucketName, objectName string, reader io.Reader, objectSizeBytes int64) error

	// Find identifies if the object can be found in the instance.
	Find(ctx context.Context, bucketName, objectName string) (bool, error)
}

ObjectReadWriteFinder defines the port to the storage instance.

type ServiceRegistryScanner added in v0.0.7

type ServiceRegistryScanner interface {
	// Scan scans the "service discovery" records to find instances and return the map ID -> IP address.
	Scan(ctx context.Context, serviceLabelFilter string) (map[string]string, error)
}

ServiceRegistryScanner defines the port to query the service registry.

type StorageConnectionFn

type StorageConnectionFn func(endpoint, accessKeyID, secretAccessKey string) (ObjectReadWriteFinder, error)

StorageConnectionFn defines the factory of ObjectReadWriteFinder.

Jump to

Keyboard shortcuts

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