Documentation ¶
Overview ¶
Package db is a generated GoMock package.
Index ¶
- Variables
- type MockStorageManager
- func (m *MockStorageManager) Add(ctx context.Context, ip string, blacklist bool) error
- func (m *MockStorageManager) Delete(ctx context.Context, ip string, blacklist bool) (int64, error)
- func (m *MockStorageManager) EXPECT() *MockStorageManagerMockRecorder
- func (m *MockStorageManager) GetIPList(ctx context.Context, blacklist bool) ([]string, error)
- func (m *MockStorageManager) GreenLightPass(ctx context.Context, ip string) error
- type MockStorageManagerMockRecorder
- func (mr *MockStorageManagerMockRecorder) Add(ctx, ip, blacklist interface{}) *gomock.Call
- func (mr *MockStorageManagerMockRecorder) Delete(ctx, ip, blacklist interface{}) *gomock.Call
- func (mr *MockStorageManagerMockRecorder) GetIPList(ctx, blacklist interface{}) *gomock.Call
- func (mr *MockStorageManagerMockRecorder) GreenLightPass(ctx, ip interface{}) *gomock.Call
- type PsqlStorage
- func (ps *PsqlStorage) Add(ctx context.Context, ip string, blacklist bool) error
- func (ps *PsqlStorage) Delete(ctx context.Context, ip string, blacklist bool) (int64, error)
- func (ps *PsqlStorage) GetIPList(ctx context.Context, blacklist bool) ([]string, error)
- func (ps *PsqlStorage) GreenLightPass(ctx context.Context, ip string) error
- type StorageManager
Constants ¶
This section is empty.
Variables ¶
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) EXPECT ¶
func (m *MockStorageManager) EXPECT() *MockStorageManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
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 ¶
Add method is used to add an IP address to a specified list (black or white)
func (*PsqlStorage) Delete ¶
Delete method is used to delete an IP address from a specified list (black or white)
func (*PsqlStorage) GetIPList ¶
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