domain

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2020 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package domain is a generated GoMock package.

Package domain is a generated GoMock package.

Package domain is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBucketFull reports faulty attempts to dispatch buckets
	ErrBucketFull = errors.New("some of the buckets returned false")
	// ErrEmptyBucketName missing bucket name error
	ErrEmptyBucketName = errors.New("empty bucket name received")
	// ErrNoBucketFound missing bucket error
	ErrNoBucketFound = errors.New("no bucket found in store")
)
View Source
var (
	// ErrEmptyIP reports empty id errors
	ErrEmptyIP = errors.New("empty IP is received")
	// ErrEmptyLogin reports empty login errors
	ErrEmptyLogin = errors.New("empty login is received")
	// ErrEmptyPWD reports empty password errors
	ErrEmptyPWD = errors.New("empty password is received")
)
View Source
var ErrDeleteMissingBucket = errors.New("no bucket found in store for deletion")

ErrDeleteMissingBucket reports an attempt to delete not-existing buckets

Functions

This section is empty.

Types

type ActiveBucketsStore

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

ActiveBucketsStore is an object that provides a storage for all buckets.

func NewActiveBucketsStore

func NewActiveBucketsStore() *ActiveBucketsStore

NewActiveBucketsStore returns a new ActiveBucketsStore object to the callee

func (*ActiveBucketsStore) AddBucket

func (abs *ActiveBucketsStore) AddBucket(name string, b Bucketer)

AddBucket adds a new bucket to the active bucket store

func (*ActiveBucketsStore) CheckBucket

func (abs *ActiveBucketsStore) CheckBucket(name string) bool

CheckBucket checks whether a requested bucket is present in the active bucket store

func (*ActiveBucketsStore) GetBucket

func (abs *ActiveBucketsStore) GetBucket(name string) (Bucketer, error)

GetBucket returns the requested bucket to the callee

func (*ActiveBucketsStore) RemoveBucket

func (abs *ActiveBucketsStore) RemoveBucket(name string) error

RemoveBucket removes a specified bucket from the active bucket store

type Bucket

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

Bucket is a structure that represents a bucket object

func NewBucket

func NewBucket(ctx context.Context, name string, count int, done chan<- string) *Bucket

NewBucket returns an new bucket object to the callee

func (*Bucket) Decrement

func (b *Bucket) Decrement() bool

Decrement reduces the bucket request counter; it return true if the request can pass and false otherwise

func (*Bucket) GetCount

func (b *Bucket) GetCount() int

GetCount returns the current count value of the bucket

func (*Bucket) Stop

func (b *Bucket) Stop()

Stop releases all the resources associated with the bucket

type Bucketer

type Bucketer interface {
	// Decrement reduces the bucket request counter; it return true if the request can pass and false otherwise
	Decrement() bool
	// GetCount returns the current count value of the bucket
	GetCount() int
	// Stop releases all the resources associated with the bucket
	Stop()
}

Bucketer allows for the communication with any created bucket

type ManageController

type ManageController interface {
	// Dispatch accepts authorisation request parameters and creates a new or decrements a counter for each bucket
	Dispatch(login string, pwd string, ip string) (bool, error)
	// FlushBuckets removes all buckets with the specified login and ip
	FlushBuckets(login string, ip string) error
	// PurgeBucket removes a bucket which name was specified as an argument
	PurgeBucket(name string) error
	// GetErrChan returns an error channel to monitor the Manager's activity
	GetErrChan() chan error
}

ManageController is a representation of a Bucket Manager interface

type Manager

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

Manager is an object that controls all the functionality to manage buckets

func NewManager

func NewManager(ctx context.Context, settings *Settings) (*Manager, error)

NewManager creates a new Manager object and returns it to the callee

func (*Manager) Dispatch

func (m *Manager) Dispatch(login, pwd, ip string) (bool, error)

Dispatch accepts authorisation request parameters and creates a new or decrements a counter for each bucket

func (*Manager) FlushBuckets

func (m *Manager) FlushBuckets(login, ip string) error

FlushBuckets removes all buckets with the specified login and ip

func (*Manager) GetErrChan

func (m *Manager) GetErrChan() chan error

GetErrChan returns an error channel to monitor the Manager's activity

func (*Manager) PurgeBucket

func (m *Manager) PurgeBucket(name string) error

PurgeBucket removes a bucket which name was specified as an argument

type MockBucketer

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

MockBucketer is a mock of Bucketer interface

func NewMockBucketer

func NewMockBucketer(ctrl *gomock.Controller) *MockBucketer

NewMockBucketer creates a new mock instance

func (*MockBucketer) Decrement

func (m *MockBucketer) Decrement() bool

Decrement mocks base method

func (*MockBucketer) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockBucketer) GetCount

func (m *MockBucketer) GetCount() int

GetCount mocks base method

func (*MockBucketer) Stop

func (m *MockBucketer) Stop()

Stop mocks base method

type MockBucketerMockRecorder

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

MockBucketerMockRecorder is the mock recorder for MockBucketer

func (*MockBucketerMockRecorder) Decrement

func (mr *MockBucketerMockRecorder) Decrement() *gomock.Call

Decrement indicates an expected call of Decrement

func (*MockBucketerMockRecorder) GetCount

func (mr *MockBucketerMockRecorder) GetCount() *gomock.Call

GetCount indicates an expected call of GetCount

func (*MockBucketerMockRecorder) Stop

func (mr *MockBucketerMockRecorder) Stop() *gomock.Call

Stop indicates an expected call of Stop

type MockManageController

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

MockManageController is a mock of ManageController interface

func NewMockManageController

func NewMockManageController(ctrl *gomock.Controller) *MockManageController

NewMockManageController creates a new mock instance

func (*MockManageController) Dispatch

func (m *MockManageController) Dispatch(login, pwd, ip string) (bool, error)

Dispatch mocks base method

func (*MockManageController) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockManageController) FlushBuckets

func (m *MockManageController) FlushBuckets(login, ip string) error

FlushBuckets mocks base method

func (*MockManageController) GetErrChan

func (m *MockManageController) GetErrChan() chan error

GetErrChan mocks base method

func (*MockManageController) PurgeBucket

func (m *MockManageController) PurgeBucket(name string) error

PurgeBucket mocks base method

type MockManageControllerMockRecorder

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

MockManageControllerMockRecorder is the mock recorder for MockManageController

func (*MockManageControllerMockRecorder) Dispatch

func (mr *MockManageControllerMockRecorder) Dispatch(login, pwd, ip interface{}) *gomock.Call

Dispatch indicates an expected call of Dispatch

func (*MockManageControllerMockRecorder) FlushBuckets

func (mr *MockManageControllerMockRecorder) FlushBuckets(login, ip interface{}) *gomock.Call

FlushBuckets indicates an expected call of FlushBuckets

func (*MockManageControllerMockRecorder) GetErrChan

func (mr *MockManageControllerMockRecorder) GetErrChan() *gomock.Call

GetErrChan indicates an expected call of GetErrChan

func (*MockManageControllerMockRecorder) PurgeBucket

func (mr *MockManageControllerMockRecorder) PurgeBucket(name interface{}) *gomock.Call

PurgeBucket indicates an expected call of PurgeBucket

type MockStorer

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

MockStorer is a mock of Storer interface

func NewMockStorer

func NewMockStorer(ctrl *gomock.Controller) *MockStorer

NewMockStorer creates a new mock instance

func (*MockStorer) AddBucket

func (m *MockStorer) AddBucket(name string, b Bucketer)

AddBucket mocks base method

func (*MockStorer) CheckBucket

func (m *MockStorer) CheckBucket(name string) bool

CheckBucket mocks base method

func (*MockStorer) EXPECT

func (m *MockStorer) EXPECT() *MockStorerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockStorer) GetBucket

func (m *MockStorer) GetBucket(name string) (Bucketer, error)

GetBucket mocks base method

func (*MockStorer) RemoveBucket

func (m *MockStorer) RemoveBucket(name string) error

RemoveBucket mocks base method

type MockStorerMockRecorder

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

MockStorerMockRecorder is the mock recorder for MockStorer

func (*MockStorerMockRecorder) AddBucket

func (mr *MockStorerMockRecorder) AddBucket(name, b interface{}) *gomock.Call

AddBucket indicates an expected call of AddBucket

func (*MockStorerMockRecorder) CheckBucket

func (mr *MockStorerMockRecorder) CheckBucket(name interface{}) *gomock.Call

CheckBucket indicates an expected call of CheckBucket

func (*MockStorerMockRecorder) GetBucket

func (mr *MockStorerMockRecorder) GetBucket(name interface{}) *gomock.Call

GetBucket indicates an expected call of GetBucket

func (*MockStorerMockRecorder) RemoveBucket

func (mr *MockStorerMockRecorder) RemoveBucket(name interface{}) *gomock.Call

RemoveBucket indicates an expected call of RemoveBucket

type Settings

type Settings struct {
	LoginLimit    int
	PasswordLimit int
	IPLimit       int
	Expire        time.Duration
}

Settings is an object that holds all the main settings for the Bucket Manager

func InitBucketManagerSettings

func InitBucketManagerSettings(cfg *config.Limits) (*Settings, error)

InitBucketManagerSettings initiates setting for the bucket manager

func (Settings) Valid

func (s Settings) Valid() bool

Valid validates the bucket manager settings

type Storer

type Storer interface {
	// GetBucket returns the requested bucket to the callee
	GetBucket(name string) (Bucketer, error)
	// CheckBucket checks whether a requested bucket is present in the active bucket store
	CheckBucket(name string) bool
	// AddBucket adds a new bucket to the active bucket store
	AddBucket(name string, b Bucketer)
	// RemoveBucket removes a specified bucket from the active bucket store
	RemoveBucket(name string) error
}

Storer provides a functionality to communicate with any bucket store that satisfies the interface

Jump to

Keyboard shortcuts

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