kss

package
v0.0.0-...-0b08f29 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	DriverType         DriverType
	LocalConfiguration *LocalConfiguration
	S3Configuration    *S3Configuration
}

Configuration contains the configuration for the KSS service

type Driver

type Driver interface {
	GetPreSignedURL(method Method, key string, expireIn time.Duration) (URL string, err error)
	Delete(key string) error
	DeleteAllWithPrefix(key string) error
	WithCallBack(FileUpdatedCallBack)
	UploadData(key string, data []byte) error
	DownloadData(key string) ([]byte, error)
}

Driver defines the interface for the KSS service

type DriverType

type DriverType string

DriverType represents the different type of KSS Drivers

const DriverTypeAWSS3 DriverType = "AWSS3"

DriverTypeAWSS3 is the AWS S3 implementation of the KSS service

const DriverTypeLocal DriverType = "Local"

DriverTypeLocal is the local filesystem implementation of the KSS service

const None DriverType = ""

None is used when there is no KSS implementation

type FileUpdatedCallBack

type FileUpdatedCallBack func(event FileUpdatedEvent) error

FileUpdatedCallBack are called when a new file has been uploaded

type FileUpdatedEvent

type FileUpdatedEvent struct {
	Type  string
	Key   string
	Etags string
	Size  int64
}

FileUpdatedEvent contains information about a file event

type LocalConfiguration

type LocalConfiguration struct {
	KeyPrefix  string
	PublicURL  string
	PrivateKey *rsa.PrivateKey
}

LocalConfiguration contains the configuration for the local filesystem KSS service

type LocalFilesystem

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

LocalFilesystem is the entity which provides local filesystem

func NewLocalFilesystem

func NewLocalFilesystem(router *mux.Router, config LocalConfiguration) (*LocalFilesystem, error)

NewLocalFilesystem returns a new LocalFilesystem

func (*LocalFilesystem) Delete

func (f *LocalFilesystem) Delete(key string) error

Delete deletes a the key file

func (*LocalFilesystem) DeleteAllWithPrefix

func (f *LocalFilesystem) DeleteAllWithPrefix(key string) error

DeleteAllWithPrefix all keys starting with

func (*LocalFilesystem) DownloadData

func (f *LocalFilesystem) DownloadData(key string) ([]byte, error)

DownloadData downloads data from key object

func (*LocalFilesystem) GetPreSignedURL

func (f *LocalFilesystem) GetPreSignedURL(method Method, key string, expireIn time.Duration) (URL string, err error)

GetPreSignedURL returns a pre-signed URL that can be used with the given method until expiry time is passed key must be a valid file name

func (*LocalFilesystem) UploadData

func (f *LocalFilesystem) UploadData(key string, data []byte) error

UploadData uploads data into a new key object

func (*LocalFilesystem) WithCallBack

func (f *LocalFilesystem) WithCallBack(callback FileUpdatedCallBack)

WithCallBack Replaces teh current callback with WithCallBack

type Method

type Method string

Method is the type of methodes supported for signed URLs

const Get Method = "GET"

Get is the Method to Get an object

const Put Method = "PUT"

Put is the Method to Put an object

type S3

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

S3 is the implementation of the KSSDriver for AWS S3

func NewS3

func NewS3(kssConfig S3Configuration) (*S3, error)

NewS3 returns a new S3

func (*S3) Delete

func (s *S3) Delete(key string) error

Delete deletes a the key file

func (*S3) DeleteAllWithPrefix

func (s *S3) DeleteAllWithPrefix(key string) error

DeleteAllWithPrefix all keys starting with

func (*S3) DownloadData

func (s *S3) DownloadData(key string) ([]byte, error)

DownloadData downloads data from key object

func (*S3) GetPreSignedURL

func (s *S3) GetPreSignedURL(method Method, key string, expireIn time.Duration) (URL string, err error)

GetPreSignedURL returns a pre-signed URL that can be used with the given method until expiry time is passed key must be a valid file name

func (*S3) ListAllWithPrefix

func (s *S3) ListAllWithPrefix(key string) (keys []string, err error)

ListAllWithPrefix Lists all keys with prefix

func (*S3) ProcessIncomingSQSMessageRecords

func (s *S3) ProcessIncomingSQSMessageRecords(messages []events.SQSMessage)

ProcessIncomingSQSMessageRecords processes messages coming from the SQS queue connected to the S3 bucket that is used by thos S3 instance

func (*S3) UploadData

func (s *S3) UploadData(key string, data []byte) error

UploadData uploads data into a new key object

func (*S3) WithCallBack

func (s *S3) WithCallBack(callback FileUpdatedCallBack)

WithCallBack Replaces the current callback with WithCallBack

type S3Configuration

type S3Configuration struct {
	// AccessID is the ID to use when accessing the S3 bucket
	AccessID string

	// AccessKey is the Key to use when accessing the S3 bucket
	AccessKey string

	// The name of the bucket to use for storing files
	AWSBucketName string

	// The AWS region in which the bucket is located
	AWSRegion string

	// The prefix that will be added to add keys
	KeyPrefix string

	// SQSNotificationQueue defines the queue to listen to get event notification
	SQSNotificationQueue string
}

S3Configuration contains the configuration for the S3 KSS service

type S3Credentials

type S3Credentials struct {
	AccessID  string `env:"S3_ACCESS_ID" description:"the access ID to kss-test bucket"`
	AccessKey string `env:"S3_ACCESS_KEY" description:"the access ID to kss-test bucket"`
}

S3Credentials contains S3 Credentials

Jump to

Keyboard shortcuts

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