config

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config 基于配置导表功能实现的配置加载及刷新功能

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(loadDir string, loadHandle LoadHandle, refreshHandle RefreshHandle)

Init 配置初始化

func Load

func Load()

Load 加载配置

  • 加载后并不会刷新线上配置,需要执行 Refresh 函数对线上配置进行刷新

func OnConfigRefreshEvent

func OnConfigRefreshEvent()

func Refresh

func Refresh()

Refresh 刷新配置

func RegConfigRefreshEvent

func RegConfigRefreshEvent(handle RefreshEventHandle)

RegConfigRefreshEvent 当配置刷新时将立即执行被注册的事件处理函数

func StopTickerLoad

func StopTickerLoad()

StopTickerLoad 停止通过定时器加载配置

func WithTickerLoad

func WithTickerLoad(ticker *timer.Ticker, interval time.Duration)

WithTickerLoad 通过定时器加载配置

  • 通过定时器加载配置后,会自动刷新线上配置
  • 调用该函数后将会立即加载并刷新一次配置,随后每隔 interval 时间加载并刷新一次配置

Types

type LoadHandle

type LoadHandle func(handle func(filename string, config any) error)

LoadHandle 配置加载处理函数

type RefreshEventHandle

type RefreshEventHandle func()

RefreshEventHandle 配置刷新事件处理函数

type RefreshHandle

type RefreshHandle func()

RefreshHandle 配置刷新处理函数

Jump to

Keyboard shortcuts

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