settings

package
v0.0.0-...-bafbf86 Latest Latest
Warning

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

Go to latest
Published: May 7, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(settings ISettings)

New - init new

Types

type Cache

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

Cache - cached info. High-level Settings Manager.

func (*Cache) AddRecord

func (p *Cache) AddRecord(newRec interface{}) error

AddRecord -

func (*Cache) GetChatInfo

func (p *Cache) GetChatInfo(chatID int64) (*raw.ChatInfo, error)

GetChatInfo -

func (*Cache) GetChatUser

func (p *Cache) GetChatUser(userID int) (*raw.ChatUser, error)

GetChatUser -

func (*Cache) GetHandlerRecords

func (p *Cache) GetHandlerRecords(out interface{}) error

GetHandlerRecords - should we cache this?

func (*Cache) Init

func (p *Cache) Init(url string) error

Init - init newely created cache

func (*Cache) UpdateRecord

func (p *Cache) UpdateRecord(newRec interface{}) error

UpdateRecord -

type ICache

type ICache interface {
	ISettings
}

ICache - ISettings decorator, cached some results

func NewCache

func NewCache(url string) (ICache, error)

NewCache - create new Cache

type ISettings

type ISettings interface {
	ISettingsOpener
	ISettingsReader
	ISettingsWriter
}

ISettings - repository

func Inst

func Inst() ISettings

Inst -singletone getter. returns already created instance

type ISettingsOpener

type ISettingsOpener interface {
	Init(url string) error
}

ISettingsOpener - access settings

type ISettingsReader

type ISettingsReader interface {
	GetChatInfo(chatID int64) (*raw.ChatInfo, error)
	GetChatUser(userID int) (*raw.ChatUser, error)
	// get all db entries, related to a definite handler (e.g. settings for a Handler)
	// Mapping interface{} to struct is up to handler
	GetHandlerRecords(out interface{}) error
}

ISettingsReader - readonly access

type ISettingsWriter

type ISettingsWriter interface {
	AddRecord(newRec interface{}) error
	UpdateRecord(modifiedRec interface{}) error
}

ISettingsWriter - add new entries

type Settings

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

Settings - one settings manager for gorm postgres db. ISettings impl

func (*Settings) AddRecord

func (p *Settings) AddRecord(newRec interface{}) error

AddRecord - insert record to db

func (*Settings) GetChatInfo

func (p *Settings) GetChatInfo(chatID int64) (*raw.ChatInfo, error)

GetChatInfo -

func (*Settings) GetChatUser

func (p *Settings) GetChatUser(userID int) (*raw.ChatUser, error)

GetChatUser -

func (*Settings) GetHandlerRecords

func (p *Settings) GetHandlerRecords(out interface{}) error

GetHandlerRecords -

func (*Settings) Init

func (p *Settings) Init(url string) error

Init - init db connection. url - dabase url

func (*Settings) UpdateRecord

func (p *Settings) UpdateRecord(newRec interface{}) error

UpdateRecord - update existing

Jump to

Keyboard shortcuts

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