filestore

package
v0.0.0-...-6e31670 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package filestore contains functionality to store Emitto rule files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGCSClient

func NewGCSClient(ctx context.Context, credFile string, scopes []string) (*storage.Client, error)

NewGCSClient initializes a new Google Cloud Storage Client. Follow these instructions to set up application credentials: https://cloud.google.com/docs/authentication/production#obtaining_and_providing_service_account_credentials_manually.

func RunTestSuite

func RunTestSuite(t *testing.T, builder func() FileStore)

RunTestSuite runs all generic store tests.

The tests use the provided builder to instantiate a FileStore. The builder is expected to always return a valid Store.

Types

type FileStore

type FileStore interface {
	// AddRuleFile creates a new rule file at the specified path.
	AddRuleFile(ctx context.Context, path string, rules []byte) error
	// GetRuleFile retrieves an existing rule file by path.
	GetRuleFile(ctx context.Context, path string) ([]byte, error)
	// DeleteRuleFile removes an existing rule file by path.
	DeleteRuleFile(ctx context.Context, path string) error
}

FileStore represents a Emitto file store.

type GCSFileStore

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

GCSFileStore is a Google Cloud Storage implementation of a FileStore.

func NewGCSFileStore

func NewGCSFileStore(bucket string, client *storage.Client) *GCSFileStore

NewGCSFileStore returns a new GCSFileStore.

func (*GCSFileStore) AddRuleFile

func (s *GCSFileStore) AddRuleFile(ctx context.Context, path string, rules []byte) error

AddRuleFile uploads a rule file to GCS.

func (*GCSFileStore) Close

func (s *GCSFileStore) Close() error

Close GCS client connection.

func (*GCSFileStore) DeleteRuleFile

func (s *GCSFileStore) DeleteRuleFile(ctx context.Context, ruleFile string) error

DeleteRuleFile removes a rule file from GCS.

func (*GCSFileStore) GetRuleFile

func (s *GCSFileStore) GetRuleFile(ctx context.Context, path string) ([]byte, error)

GetRuleFile returns a rule file from GCS.

type MemoryFileStore

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

MemoryFileStore a memory implementation of a FileStore.

func NewMemoryFileStore

func NewMemoryFileStore() *MemoryFileStore

NewMemoryFileStore returns a MemoryFileStore.

func (*MemoryFileStore) AddRuleFile

func (s *MemoryFileStore) AddRuleFile(ctx context.Context, path string, rules []byte) error

AddRuleFile stores a rule file in the filestore.

func (*MemoryFileStore) DeleteRuleFile

func (s *MemoryFileStore) DeleteRuleFile(ctx context.Context, path string) error

DeleteRuleFile removes a rule file from the filestore.

func (*MemoryFileStore) GetRuleFile

func (s *MemoryFileStore) GetRuleFile(ctx context.Context, path string) ([]byte, error)

GetRuleFile retrieves a rule file from the filestore.

Jump to

Keyboard shortcuts

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