database

package
v0.0.0-...-2ec280d Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIServer

type APIServer interface {
	ReadDevices(ctx context.Context) ([]*pb.Device, error)
	UpdateDevices(ctx context.Context, devices []*pb.Device) error
	UpdateGateway(ctx context.Context, gateway *pb.Gateway) error
	UpdateGatewayDynamicFields(ctx context.Context, gateway *pb.Gateway) error
	AddGateway(ctx context.Context, gateway *pb.Gateway) error
	AddDevice(ctx context.Context, device *pb.Device) error
	ReadDevice(ctx context.Context, publicKey string) (*pb.Device, error)
	ReadDeviceById(ctx context.Context, deviceID int64) (*pb.Device, error)
	ReadGateways(ctx context.Context) ([]*pb.Gateway, error)
	ReadGateway(ctx context.Context, name string) (*pb.Gateway, error)
	ReadDeviceBySerialPlatform(ctx context.Context, serial string, platform string) (*pb.Device, error)
	AddSessionInfo(ctx context.Context, si *pb.Session) error
	ReadSessionInfo(ctx context.Context, key string) (*pb.Session, error)
	ReadSessionInfos(ctx context.Context) ([]*pb.Session, error)
	RemoveExpiredSessions(ctx context.Context) error
	ReadMostRecentSessionInfo(ctx context.Context, deviceID int64) (*pb.Session, error)
}

func New

func New(_ context.Context, dbPath string, v4Allocator ip.Allocator, v6Allocator ip.Allocator, defaultDeviceHealth bool) (APIServer, error)

type ApiServerDB

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

func (*ApiServerDB) AddDevice

func (db *ApiServerDB) AddDevice(ctx context.Context, device *pb.Device) error

func (*ApiServerDB) AddGateway

func (db *ApiServerDB) AddGateway(ctx context.Context, gw *pb.Gateway) error

func (*ApiServerDB) AddSessionInfo

func (db *ApiServerDB) AddSessionInfo(ctx context.Context, si *pb.Session) error

func (*ApiServerDB) ReadDevice

func (db *ApiServerDB) ReadDevice(ctx context.Context, publicKey string) (*pb.Device, error)

func (*ApiServerDB) ReadDeviceById

func (db *ApiServerDB) ReadDeviceById(ctx context.Context, deviceID int64) (*pb.Device, error)

func (*ApiServerDB) ReadDeviceBySerialPlatform

func (db *ApiServerDB) ReadDeviceBySerialPlatform(ctx context.Context, serial, platform string) (*pb.Device, error)

func (*ApiServerDB) ReadDevices

func (db *ApiServerDB) ReadDevices(ctx context.Context) ([]*pb.Device, error)

func (*ApiServerDB) ReadGateway

func (db *ApiServerDB) ReadGateway(ctx context.Context, name string) (*pb.Gateway, error)

func (*ApiServerDB) ReadGateways

func (db *ApiServerDB) ReadGateways(ctx context.Context) ([]*pb.Gateway, error)

func (*ApiServerDB) ReadMostRecentSessionInfo

func (db *ApiServerDB) ReadMostRecentSessionInfo(ctx context.Context, deviceID int64) (*pb.Session, error)

func (*ApiServerDB) ReadSessionInfo

func (db *ApiServerDB) ReadSessionInfo(ctx context.Context, key string) (*pb.Session, error)

func (*ApiServerDB) ReadSessionInfos

func (db *ApiServerDB) ReadSessionInfos(ctx context.Context) ([]*pb.Session, error)

func (*ApiServerDB) RemoveExpiredSessions

func (db *ApiServerDB) RemoveExpiredSessions(ctx context.Context) error

func (*ApiServerDB) UpdateDevices

func (db *ApiServerDB) UpdateDevices(ctx context.Context, devices []*pb.Device) error

func (*ApiServerDB) UpdateGateway

func (db *ApiServerDB) UpdateGateway(ctx context.Context, gw *pb.Gateway) error

func (*ApiServerDB) UpdateGatewayDynamicFields

func (db *ApiServerDB) UpdateGatewayDynamicFields(ctx context.Context, gw *pb.Gateway) error

type MockAPIServer

type MockAPIServer struct {
	mock.Mock
}

MockAPIServer is an autogenerated mock type for the APIServer type

func NewMockAPIServer

func NewMockAPIServer(t interface {
	mock.TestingT
	Cleanup(func())
},
) *MockAPIServer

NewMockAPIServer creates a new instance of MockAPIServer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockAPIServer) AddDevice

func (_m *MockAPIServer) AddDevice(ctx context.Context, device *pb.Device) error

AddDevice provides a mock function with given fields: ctx, device

func (*MockAPIServer) AddGateway

func (_m *MockAPIServer) AddGateway(ctx context.Context, gateway *pb.Gateway) error

AddGateway provides a mock function with given fields: ctx, gateway

func (*MockAPIServer) AddSessionInfo

func (_m *MockAPIServer) AddSessionInfo(ctx context.Context, si *pb.Session) error

AddSessionInfo provides a mock function with given fields: ctx, si

func (*MockAPIServer) EXPECT

func (_m *MockAPIServer) EXPECT() *MockAPIServer_Expecter

func (*MockAPIServer) ReadDevice

func (_m *MockAPIServer) ReadDevice(ctx context.Context, publicKey string) (*pb.Device, error)

ReadDevice provides a mock function with given fields: ctx, publicKey

func (*MockAPIServer) ReadDeviceById

func (_m *MockAPIServer) ReadDeviceById(ctx context.Context, deviceID int64) (*pb.Device, error)

ReadDeviceById provides a mock function with given fields: ctx, deviceID

func (*MockAPIServer) ReadDeviceBySerialPlatform

func (_m *MockAPIServer) ReadDeviceBySerialPlatform(ctx context.Context, serial string, platform string) (*pb.Device, error)

ReadDeviceBySerialPlatform provides a mock function with given fields: ctx, serial, platform

func (*MockAPIServer) ReadDevices

func (_m *MockAPIServer) ReadDevices(ctx context.Context) ([]*pb.Device, error)

ReadDevices provides a mock function with given fields: ctx

func (*MockAPIServer) ReadGateway

func (_m *MockAPIServer) ReadGateway(ctx context.Context, name string) (*pb.Gateway, error)

ReadGateway provides a mock function with given fields: ctx, name

func (*MockAPIServer) ReadGateways

func (_m *MockAPIServer) ReadGateways(ctx context.Context) ([]*pb.Gateway, error)

ReadGateways provides a mock function with given fields: ctx

func (*MockAPIServer) ReadMostRecentSessionInfo

func (_m *MockAPIServer) ReadMostRecentSessionInfo(ctx context.Context, deviceID int64) (*pb.Session, error)

ReadMostRecentSessionInfo provides a mock function with given fields: ctx, deviceID

func (*MockAPIServer) ReadSessionInfo

func (_m *MockAPIServer) ReadSessionInfo(ctx context.Context, key string) (*pb.Session, error)

ReadSessionInfo provides a mock function with given fields: ctx, key

func (*MockAPIServer) ReadSessionInfos

func (_m *MockAPIServer) ReadSessionInfos(ctx context.Context) ([]*pb.Session, error)

ReadSessionInfos provides a mock function with given fields: ctx

func (*MockAPIServer) RemoveExpiredSessions

func (_m *MockAPIServer) RemoveExpiredSessions(ctx context.Context) error

RemoveExpiredSessions provides a mock function with given fields: ctx

func (*MockAPIServer) UpdateDevices

func (_m *MockAPIServer) UpdateDevices(ctx context.Context, devices []*pb.Device) error

UpdateDevices provides a mock function with given fields: ctx, devices

func (*MockAPIServer) UpdateGateway

func (_m *MockAPIServer) UpdateGateway(ctx context.Context, gateway *pb.Gateway) error

UpdateGateway provides a mock function with given fields: ctx, gateway

func (*MockAPIServer) UpdateGatewayDynamicFields

func (_m *MockAPIServer) UpdateGatewayDynamicFields(ctx context.Context, gateway *pb.Gateway) error

UpdateGatewayDynamicFields provides a mock function with given fields: ctx, gateway

type MockAPIServer_AddDevice_Call

type MockAPIServer_AddDevice_Call struct {
	*mock.Call
}

MockAPIServer_AddDevice_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddDevice'

func (*MockAPIServer_AddDevice_Call) Return

func (*MockAPIServer_AddDevice_Call) Run

func (*MockAPIServer_AddDevice_Call) RunAndReturn

type MockAPIServer_AddGateway_Call

type MockAPIServer_AddGateway_Call struct {
	*mock.Call
}

MockAPIServer_AddGateway_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddGateway'

func (*MockAPIServer_AddGateway_Call) Return

func (*MockAPIServer_AddGateway_Call) Run

func (*MockAPIServer_AddGateway_Call) RunAndReturn

type MockAPIServer_AddSessionInfo_Call

type MockAPIServer_AddSessionInfo_Call struct {
	*mock.Call
}

MockAPIServer_AddSessionInfo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddSessionInfo'

func (*MockAPIServer_AddSessionInfo_Call) Return

func (*MockAPIServer_AddSessionInfo_Call) Run

func (*MockAPIServer_AddSessionInfo_Call) RunAndReturn

type MockAPIServer_Expecter

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

func (*MockAPIServer_Expecter) AddDevice

func (_e *MockAPIServer_Expecter) AddDevice(ctx interface{}, device interface{}) *MockAPIServer_AddDevice_Call

AddDevice is a helper method to define mock.On call

  • ctx context.Context
  • device *pb.Device

func (*MockAPIServer_Expecter) AddGateway

func (_e *MockAPIServer_Expecter) AddGateway(ctx interface{}, gateway interface{}) *MockAPIServer_AddGateway_Call

AddGateway is a helper method to define mock.On call

  • ctx context.Context
  • gateway *pb.Gateway

func (*MockAPIServer_Expecter) AddSessionInfo

func (_e *MockAPIServer_Expecter) AddSessionInfo(ctx interface{}, si interface{}) *MockAPIServer_AddSessionInfo_Call

AddSessionInfo is a helper method to define mock.On call

  • ctx context.Context
  • si *pb.Session

func (*MockAPIServer_Expecter) ReadDevice

func (_e *MockAPIServer_Expecter) ReadDevice(ctx interface{}, publicKey interface{}) *MockAPIServer_ReadDevice_Call

ReadDevice is a helper method to define mock.On call

  • ctx context.Context
  • publicKey string

func (*MockAPIServer_Expecter) ReadDeviceById

func (_e *MockAPIServer_Expecter) ReadDeviceById(ctx interface{}, deviceID interface{}) *MockAPIServer_ReadDeviceById_Call

ReadDeviceById is a helper method to define mock.On call

  • ctx context.Context
  • deviceID int64

func (*MockAPIServer_Expecter) ReadDeviceBySerialPlatform

func (_e *MockAPIServer_Expecter) ReadDeviceBySerialPlatform(ctx interface{}, serial interface{}, platform interface{}) *MockAPIServer_ReadDeviceBySerialPlatform_Call

ReadDeviceBySerialPlatform is a helper method to define mock.On call

  • ctx context.Context
  • serial string
  • platform string

func (*MockAPIServer_Expecter) ReadDevices

func (_e *MockAPIServer_Expecter) ReadDevices(ctx interface{}) *MockAPIServer_ReadDevices_Call

ReadDevices is a helper method to define mock.On call

  • ctx context.Context

func (*MockAPIServer_Expecter) ReadGateway

func (_e *MockAPIServer_Expecter) ReadGateway(ctx interface{}, name interface{}) *MockAPIServer_ReadGateway_Call

ReadGateway is a helper method to define mock.On call

  • ctx context.Context
  • name string

func (*MockAPIServer_Expecter) ReadGateways

func (_e *MockAPIServer_Expecter) ReadGateways(ctx interface{}) *MockAPIServer_ReadGateways_Call

ReadGateways is a helper method to define mock.On call

  • ctx context.Context

func (*MockAPIServer_Expecter) ReadMostRecentSessionInfo

func (_e *MockAPIServer_Expecter) ReadMostRecentSessionInfo(ctx interface{}, deviceID interface{}) *MockAPIServer_ReadMostRecentSessionInfo_Call

ReadMostRecentSessionInfo is a helper method to define mock.On call

  • ctx context.Context
  • deviceID int64

func (*MockAPIServer_Expecter) ReadSessionInfo

func (_e *MockAPIServer_Expecter) ReadSessionInfo(ctx interface{}, key interface{}) *MockAPIServer_ReadSessionInfo_Call

ReadSessionInfo is a helper method to define mock.On call

  • ctx context.Context
  • key string

func (*MockAPIServer_Expecter) ReadSessionInfos

func (_e *MockAPIServer_Expecter) ReadSessionInfos(ctx interface{}) *MockAPIServer_ReadSessionInfos_Call

ReadSessionInfos is a helper method to define mock.On call

  • ctx context.Context

func (*MockAPIServer_Expecter) RemoveExpiredSessions

func (_e *MockAPIServer_Expecter) RemoveExpiredSessions(ctx interface{}) *MockAPIServer_RemoveExpiredSessions_Call

RemoveExpiredSessions is a helper method to define mock.On call

  • ctx context.Context

func (*MockAPIServer_Expecter) UpdateDevices

func (_e *MockAPIServer_Expecter) UpdateDevices(ctx interface{}, devices interface{}) *MockAPIServer_UpdateDevices_Call

UpdateDevices is a helper method to define mock.On call

  • ctx context.Context
  • devices []*pb.Device

func (*MockAPIServer_Expecter) UpdateGateway

func (_e *MockAPIServer_Expecter) UpdateGateway(ctx interface{}, gateway interface{}) *MockAPIServer_UpdateGateway_Call

UpdateGateway is a helper method to define mock.On call

  • ctx context.Context
  • gateway *pb.Gateway

func (*MockAPIServer_Expecter) UpdateGatewayDynamicFields

func (_e *MockAPIServer_Expecter) UpdateGatewayDynamicFields(ctx interface{}, gateway interface{}) *MockAPIServer_UpdateGatewayDynamicFields_Call

UpdateGatewayDynamicFields is a helper method to define mock.On call

  • ctx context.Context
  • gateway *pb.Gateway

type MockAPIServer_ReadDeviceById_Call

type MockAPIServer_ReadDeviceById_Call struct {
	*mock.Call
}

MockAPIServer_ReadDeviceById_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReadDeviceById'

func (*MockAPIServer_ReadDeviceById_Call) Return

func (*MockAPIServer_ReadDeviceById_Call) Run

func (*MockAPIServer_ReadDeviceById_Call) RunAndReturn

type MockAPIServer_ReadDeviceBySerialPlatform_Call

type MockAPIServer_ReadDeviceBySerialPlatform_Call struct {
	*mock.Call
}

MockAPIServer_ReadDeviceBySerialPlatform_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReadDeviceBySerialPlatform'

func (*MockAPIServer_ReadDeviceBySerialPlatform_Call) Return

func (*MockAPIServer_ReadDeviceBySerialPlatform_Call) Run

func (*MockAPIServer_ReadDeviceBySerialPlatform_Call) RunAndReturn

type MockAPIServer_ReadDevice_Call

type MockAPIServer_ReadDevice_Call struct {
	*mock.Call
}

MockAPIServer_ReadDevice_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReadDevice'

func (*MockAPIServer_ReadDevice_Call) Return

func (*MockAPIServer_ReadDevice_Call) Run

func (*MockAPIServer_ReadDevice_Call) RunAndReturn

type MockAPIServer_ReadDevices_Call

type MockAPIServer_ReadDevices_Call struct {
	*mock.Call
}

MockAPIServer_ReadDevices_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReadDevices'

func (*MockAPIServer_ReadDevices_Call) Return

func (*MockAPIServer_ReadDevices_Call) Run

func (*MockAPIServer_ReadDevices_Call) RunAndReturn

type MockAPIServer_ReadGateway_Call

type MockAPIServer_ReadGateway_Call struct {
	*mock.Call
}

MockAPIServer_ReadGateway_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReadGateway'

func (*MockAPIServer_ReadGateway_Call) Return

func (*MockAPIServer_ReadGateway_Call) Run

func (*MockAPIServer_ReadGateway_Call) RunAndReturn

type MockAPIServer_ReadGateways_Call

type MockAPIServer_ReadGateways_Call struct {
	*mock.Call
}

MockAPIServer_ReadGateways_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReadGateways'

func (*MockAPIServer_ReadGateways_Call) Return

func (*MockAPIServer_ReadGateways_Call) Run

func (*MockAPIServer_ReadGateways_Call) RunAndReturn

type MockAPIServer_ReadMostRecentSessionInfo_Call

type MockAPIServer_ReadMostRecentSessionInfo_Call struct {
	*mock.Call
}

MockAPIServer_ReadMostRecentSessionInfo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReadMostRecentSessionInfo'

func (*MockAPIServer_ReadMostRecentSessionInfo_Call) Return

func (*MockAPIServer_ReadMostRecentSessionInfo_Call) Run

func (*MockAPIServer_ReadMostRecentSessionInfo_Call) RunAndReturn

type MockAPIServer_ReadSessionInfo_Call

type MockAPIServer_ReadSessionInfo_Call struct {
	*mock.Call
}

MockAPIServer_ReadSessionInfo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReadSessionInfo'

func (*MockAPIServer_ReadSessionInfo_Call) Return

func (*MockAPIServer_ReadSessionInfo_Call) Run

func (*MockAPIServer_ReadSessionInfo_Call) RunAndReturn

type MockAPIServer_ReadSessionInfos_Call

type MockAPIServer_ReadSessionInfos_Call struct {
	*mock.Call
}

MockAPIServer_ReadSessionInfos_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReadSessionInfos'

func (*MockAPIServer_ReadSessionInfos_Call) Return

func (*MockAPIServer_ReadSessionInfos_Call) Run

func (*MockAPIServer_ReadSessionInfos_Call) RunAndReturn

type MockAPIServer_RemoveExpiredSessions_Call

type MockAPIServer_RemoveExpiredSessions_Call struct {
	*mock.Call
}

MockAPIServer_RemoveExpiredSessions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveExpiredSessions'

func (*MockAPIServer_RemoveExpiredSessions_Call) Return

func (*MockAPIServer_RemoveExpiredSessions_Call) Run

func (*MockAPIServer_RemoveExpiredSessions_Call) RunAndReturn

type MockAPIServer_UpdateDevices_Call

type MockAPIServer_UpdateDevices_Call struct {
	*mock.Call
}

MockAPIServer_UpdateDevices_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDevices'

func (*MockAPIServer_UpdateDevices_Call) Return

func (*MockAPIServer_UpdateDevices_Call) Run

func (*MockAPIServer_UpdateDevices_Call) RunAndReturn

type MockAPIServer_UpdateGatewayDynamicFields_Call

type MockAPIServer_UpdateGatewayDynamicFields_Call struct {
	*mock.Call
}

MockAPIServer_UpdateGatewayDynamicFields_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateGatewayDynamicFields'

func (*MockAPIServer_UpdateGatewayDynamicFields_Call) Return

func (*MockAPIServer_UpdateGatewayDynamicFields_Call) Run

func (*MockAPIServer_UpdateGatewayDynamicFields_Call) RunAndReturn

type MockAPIServer_UpdateGateway_Call

type MockAPIServer_UpdateGateway_Call struct {
	*mock.Call
}

MockAPIServer_UpdateGateway_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateGateway'

func (*MockAPIServer_UpdateGateway_Call) Return

func (*MockAPIServer_UpdateGateway_Call) Run

func (*MockAPIServer_UpdateGateway_Call) RunAndReturn

type Querier

type Querier interface {
	sqlc.Querier
	Transaction(ctx context.Context, callback func(ctx context.Context, queries *sqlc.Queries) error) error
}

type Queries

type Queries struct {
	*sqlc.Queries
	// contains filtered or unexported fields
}

func NewQuerier

func NewQuerier(db *sql.DB) *Queries

func (*Queries) Transaction

func (q *Queries) Transaction(ctx context.Context, callback func(ctx context.Context, queries *sqlc.Queries) error) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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