state

package
v0.251008.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2025 License: CC0-1.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const ContextKey = "run/state-global"

Variables

This section is empty.

Functions

func ByteToBool

func ByteToBool(b []byte) bool

func ByteToInt8

func ByteToInt8(b []byte) int8

func ConfigInt added in v0.241202.0

func ConfigInt(fromConfig int, mininalValue int, defaultValue int) int

the value in the configuration should not be less than the minimal value значение в конфигурации не должно быть меньше минимального значения

func ConfigString added in v0.241202.0

func ConfigString(configValue string, defaultValue string) string

if the value is not set in the configuration, then return the default value если значение в конфигурации не установлено, тогда возвращаем значение по умолчанию

func Log2stdlib

func Log2stdlib(l2 *log2.Log) *log.Logger

TODO func (*log2.Log) Stdlib() *log.Logger

Types

type Config

type Config struct {

	// only used for Unmarshal, do not access
	XXX_Include []ConfigSource `hcl:"include"`

	DB struct {
		PingTimeoutMs int    `hcl:"ping_timeout_ms"`
		URL           string `hcl:"url"`
	}
	Money struct {
		Scale int `hcl:"scale"`
	}
	Tax struct {
		DebugLevel int `hcl:"debug_level"`
		Ru2019     struct {
			Tag1009 string // payment address
			Tag1187 string // payment place
			Tag1018 string // business INN
			Tag1055 int    // uint32 tax form
			Tag1199 int    // uint32 tax rate
			Umka    struct {
				BaseURL string `hcl:"base_url"`

				XXX_testRT http.RoundTripper `hcl:"-"`
			}
		}
	}
	CashLess struct {
		DebugLevel                                 int
		TerminalKey                                string
		TerminalPass                               string
		QRValidTimeSec                             int    // order validation time. время валидности заказа
		TerminalQRPayRefreshSec                    int    // interval manualy cheking payment status. как часто опрашивать статус оплаты. во время валидного времени заказа
		TerminalBankCommission                     int    // bank commision. ( 1 = 0.01% ) комиссия бынка в сотых процента/
		TerminalMinimalAmount                      int    // minimal order amount. минимальная суммв заказа в копейках
		URLToListenToBankNotifications             string // URL for incoming notifications. ссылка для банки, куда слать уведомления.
		TimeoutToStartManualPaymentVerificationSec int    // after how many seconds to start checking the payment status manually. через сколько секунд начать проверять статус оплаты вручную
	}
	Telegram struct {
		TelegrammBotApi string `hcl:"telegram_bot_api"`
		TelegramAdmin   int64  `hcl:"telegram_admin"`
		DebugMessages   bool   `hcl:"telegram_debug"`
		AdminBot        string `hcl:"admin_bot_name"`
	}
	Tele tele_config.Config
	// contains filtered or unexported fields
}

func MustReadConfig

func MustReadConfig(log *log2.Log, fs FullReader, names ...string) *Config

func ReadConfig

func ReadConfig(log *log2.Log, fs FullReader, names ...string) (*Config, error)

func (*Config) ScaleA

func (c *Config) ScaleA(a currency.Amount) currency.Amount

func (*Config) ScaleI

func (c *Config) ScaleI(i int) currency.Amount

func (*Config) ScaleU

func (c *Config) ScaleU(u uint32) currency.Amount

type ConfigSource

type ConfigSource struct {
	Name     string `hcl:"name,key"`
	Optional bool   `hcl:"optional"`
}

type FullReader

type FullReader interface {
	Normalize(key string) string
	// nil,nil = not found
	ReadAll(key string) ([]byte, error)
}

type Global

type Global struct {
	Alive        *alive.Alive
	BuildVersion string
	Config       *Config
	DB           *pg.DB
	Log          *log2.Log
	Tele         tele_api.Teler
	Vmc          map[int32]*vmcStruct
}

func GetGlobal

func GetGlobal(ctx context.Context) *Global

func (*Global) Error

func (g *Global) Error(err error, args ...interface{})

func (*Global) GetRoboState

func (g *Global) GetRoboState(vmid int32) vender_api.State

func (*Global) InitDB

func (g *Global) InitDB(cmdName string) error

func (*Global) InitVMC

func (g *Global) InitVMC()

func (*Global) ItsWaitPayment

func (g *Global) ItsWaitPayment(p tele_api.Packet) (bool, *tele.Response)

func (*Global) ParseFromRobo

func (g *Global) ParseFromRobo(p tele_api.Packet) *tele.FromRoboMessage

фиксирует подсоединение робота или парсит пакет на команду. fixes the connection of the robot or parses the packet on the command.

func (*Global) ParseMqttPacket

func (g *Global) ParseMqttPacket(p tele_api.Packet) *tele.Response

OLD фиксирует подсоединение робота или парсит пакет на команду. fixes the connection of the robot or parses the packet on the command.

func (*Global) ReadRoboStateFromDB added in v0.241024.0

func (g *Global) ReadRoboStateFromDB(vmid int32) vender_api.State

func (*Global) RobotConnected

func (g *Global) RobotConnected(vmid int32) bool

func (*Global) SetRoboState

func (g *Global) SetRoboState(vmid int32, st vender_api.State)

func (*Global) VMCErrorWriteDb added in v0.241202.0

func (g *Global) VMCErrorWriteDb(vmid int32, message string, level ...int)

сохраняет ошибку в базу с маркировкой не просмотрено. saves the error to the base marked not viewed. level - указать какая функция вызвала эту функцию.

type MockFullReader

type MockFullReader struct {
	Map map[string]string
}

func NewMockFullReader

func NewMockFullReader(sources map[string]string) *MockFullReader

func (*MockFullReader) Normalize

func (self *MockFullReader) Normalize(name string) string

func (*MockFullReader) ReadAll

func (self *MockFullReader) ReadAll(name string) ([]byte, error)

type OsFullReader

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

func NewOsFullReader

func NewOsFullReader() *OsFullReader

func (OsFullReader) Normalize

func (self OsFullReader) Normalize(path string) string

func (*OsFullReader) ReadAll

func (self *OsFullReader) ReadAll(path string) ([]byte, error)

func (*OsFullReader) SetBase

func (self *OsFullReader) SetBase(path string)

Directories

Path Synopsis
Sorry, workaround to import cycles.
Sorry, workaround to import cycles.

Jump to

Keyboard shortcuts

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