db

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 db is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAlreadyStored reports IP duplication errors
	ErrAlreadyStored = errors.New("provided IP is already stored")
	// ErrDoesNotExist reports unknown IP querying errors
	ErrDoesNotExist = errors.New("provided IP does not exist in the DB")
	// ErrIsInTheBlacklist reports querying blacklisted IP from the whitelist
	ErrIsInTheBlacklist = errors.New("the ip is in the blacklist")
)

Functions

This section is empty.

Types

type MockStorageManager

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

MockStorageManager is a mock of StorageManager interface

func NewMockStorageManager

func NewMockStorageManager(ctrl *gomock.Controller) *MockStorageManager

NewMockStorageManager creates a new mock instance

func (*MockStorageManager) Add

func (m *MockStorageManager) Add(ctx context.Context, ip string, blacklist bool) error

Add mocks base method

func (*MockStorageManager) Delete

func (m *MockStorageManager) Delete(ctx context.Context, ip string, blacklist bool) (int64, error)

Delete mocks base method

func (*MockStorageManager) EXPECT

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

func (*MockStorageManager) GetIPList

func (m *MockStorageManager) GetIPList(ctx context.Context, blacklist bool) ([]string, error)

GetIPList mocks base method

func (*MockStorageManager) GreenLightPass

func (m *MockStorageManager) GreenLightPass(ctx context.Context, ip string) error

GreenLightPass mocks base method

type MockStorageManagerMockRecorder

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

MockStorageManagerMockRecorder is the mock recorder for MockStorageManager

func (*MockStorageManagerMockRecorder) Add

func (mr *MockStorageManagerMockRecorder) Add(ctx, ip, blacklist interface{}) *gomock.Call

Add indicates an expected call of Add

func (*MockStorageManagerMockRecorder) Delete

func (mr *MockStorageManagerMockRecorder) Delete(ctx, ip, blacklist interface{}) *gomock.Call

Delete indicates an expected call of Delete

func (*MockStorageManagerMockRecorder) GetIPList

func (mr *MockStorageManagerMockRecorder) GetIPList(ctx, blacklist interface{}) *gomock.Call

GetIPList indicates an expected call of GetIPList

func (*MockStorageManagerMockRecorder) GreenLightPass

func (mr *MockStorageManagerMockRecorder) GreenLightPass(ctx, ip interface{}) *gomock.Call

GreenLightPass indicates an expected call of GreenLightPass

type PsqlStorage

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

PsqlStorage object holds everything related to the DB interactions

func NewPsqlStorage

func NewPsqlStorage(cfg *config.DBConf) (*PsqlStorage, error)

NewPsqlStorage returns new PsqlStorage object to the callee

func (*PsqlStorage) Add

func (ps *PsqlStorage) Add(ctx context.Context, ip string, blacklist bool) error

Add method is used to add an IP address to a specified list (black or white)

func (*PsqlStorage) Delete

func (ps *PsqlStorage) Delete(ctx context.Context, ip string, blacklist bool) (int64, error)

Delete method is used to delete an IP address from a specified list (black or white)

func (*PsqlStorage) GetIPList

func (ps *PsqlStorage) GetIPList(ctx context.Context, blacklist bool) ([]string, error)

GetIPList returns an IP list requested by the callee (black or white)

func (*PsqlStorage) GreenLightPass

func (ps *PsqlStorage) GreenLightPass(ctx context.Context, ip string) error

GreenLightPass is a method that checks whether an ip is not in the black list

type StorageManager

type StorageManager interface {
	// Add adds the IP to either the whitelist or the blacklist of the app
	Add(ctx context.Context, ip string, blacklist bool) error
	// Delete removes the IP from either the whitelist or the blacklist
	Delete(ctx context.Context, ip string, blacklist bool) (int64, error)
	// GetIPList either deletes the IP from the whitelist or the blacklist of the app
	GetIPList(ctx context.Context, blacklist bool) ([]string, error)
	// ExistInList checks whether an ip exists in a specified list
	GreenLightPass(ctx context.Context, ip string) error
}

StorageManager is an interface to communicate with the DB

Jump to

Keyboard shortcuts

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