badger

package
v0.0.0-...-f97b84d Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigType

type ConfigType string

ConfigType is an enum to represent different configuration types

const (
	DeviceConfigType   ConfigType = "device"
	MpesaConfigType    ConfigType = "mpesa"
	RadiusConfigType   ConfigType = "radius"
	DatabaseConfigType ConfigType = "database"
)

type DatabaseConfigWrapper

type DatabaseConfigWrapper struct {
	// databaseconfig.DatabaseConfig
	ID          string
	ISPID       string
	Host        string
	Port        int
	Username    string
	Password    string
	Database    string
	Description string
}

DatabaseConfigWrapper wraps the hypothetical databaseconfig.DatabaseConfig

func (DatabaseConfigWrapper) GetID

func (w DatabaseConfigWrapper) GetID() string

GetID implements StorableConfig

func (DatabaseConfigWrapper) GetISPID

func (w DatabaseConfigWrapper) GetISPID() string

GetISPID implements StorableConfig

func (DatabaseConfigWrapper) GetType

func (w DatabaseConfigWrapper) GetType() ConfigType

GetType implements StorableConfig

type DeviceConfigWrapper

type DeviceConfigWrapper struct {
	gconfig.DeviceConfig
}

DeviceConfigWrapper wraps the gconfig.DeviceConfig to implement StorableConfig

func (DeviceConfigWrapper) GetID

func (w DeviceConfigWrapper) GetID() string

GetID implements StorableConfig

func (DeviceConfigWrapper) GetISPID

func (w DeviceConfigWrapper) GetISPID() string

GetISPID implements StorableConfig

func (DeviceConfigWrapper) GetType

func (w DeviceConfigWrapper) GetType() ConfigType

GetType implements StorableConfig

type MpesaConfigWrapper

type MpesaConfigWrapper struct {
	// mpesaconfig.MpesaConfig
	ID    string
	ISPID string
	Name  string
}

MpesaConfigWrapper wraps the hypothetical mpesaconfig.MpesaConfig

func (MpesaConfigWrapper) GetID

func (w MpesaConfigWrapper) GetID() string

GetID implements StorableConfig

func (MpesaConfigWrapper) GetISPID

func (w MpesaConfigWrapper) GetISPID() string

GetISPID implements StorableConfig

func (MpesaConfigWrapper) GetType

func (w MpesaConfigWrapper) GetType() ConfigType

GetType implements StorableConfig

type RadiusConfigWrapper

type RadiusConfigWrapper struct {
	// radiusconfig.RadiusConfig
	ID          string
	ISPID       string
	Server      string
	Port        int
	Secret      string
	Description string
}

RadiusConfigWrapper wraps the hypothetical radiusconfig.RadiusConfig

func (RadiusConfigWrapper) GetID

func (w RadiusConfigWrapper) GetID() string

GetID implements StorableConfig

func (RadiusConfigWrapper) GetISPID

func (w RadiusConfigWrapper) GetISPID() string

GetISPID implements StorableConfig

func (RadiusConfigWrapper) GetType

func (w RadiusConfigWrapper) GetType() ConfigType

GetType implements StorableConfig

type StorableConfig

type StorableConfig interface {
	GetID() string
	GetISPID() string // Optional, but useful for organization
	GetType() ConfigType
}

StorableConfig is an interface that all configuration types should implement

type Store

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

Store represents the generic storage layer

func NewStore

func NewStore() (*Store, error)

NewStore creates a new storage instance

func (*Store) Close

func (s *Store) Close() error

Close closes the database

func (*Store) DeleteConfig

func (s *Store) DeleteConfig(configType ConfigType, id string) error

DeleteConfig deletes a configuration by its type and ID

func (*Store) DeleteSessionValue

func (s *Store) DeleteSessionValue(sessionID, key string) error

DeleteSessionValue deletes a value associated with a session ID

func (*Store) GetConfig

func (s *Store) GetConfig(configType ConfigType, id string, out interface{}) error

GetConfig retrieves a configuration by its type and ID

func (*Store) GetSessionValue

func (s *Store) GetSessionValue(sessionID, key string) ([]byte, error)

GetSessionValue retrieves a value associated with a session ID

func (*Store) ListConfigsByISP

func (s *Store) ListConfigsByISP(ispID string, configType ConfigType, outSlice interface{}) error

ListConfigsByISP lists all configurations of a specific type for a given ISP

func (*Store) ListDatabaseConfigsByISP

func (s *Store) ListDatabaseConfigsByISP(ispID string) ([]DatabaseConfigWrapper, error)

func (*Store) ListDeviceConfigsByISP

func (s *Store) ListDeviceConfigsByISP(ispID string) ([]gconfig.DeviceConfig, error)

func (*Store) ListMpesaConfigsByISP

func (s *Store) ListMpesaConfigsByISP(ispID string) ([]MpesaConfigWrapper, error)

func (*Store) ListRadiusConfigsByISP

func (s *Store) ListRadiusConfigsByISP(ispID string) ([]RadiusConfigWrapper, error)

func (*Store) SaveConfig

func (s *Store) SaveConfig(config StorableConfig) error

SaveConfig saves a configuration of any supported type

func (*Store) SaveSessionValue

func (s *Store) SaveSessionValue(sessionID, key string, value []byte, ttl time.Duration) error

SaveSessionValue saves a value associated with a session ID

Jump to

Keyboard shortcuts

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