config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CfgFileName = "lsobus.json"
)

Variables

This section is empty.

Functions

func DefaultDataDir

func DefaultDataDir() string

DefaultDataDir is the default data directory to use for the databases and other persistence requirements.

func TestDataDir

func TestDataDir() string

Types

type CfgManager

type CfgManager struct {
	ConfigFile string
	// contains filtered or unexported fields
}

func NewCfgManager

func NewCfgManager(path string) *CfgManager

func NewCfgManagerWithFile

func NewCfgManagerWithFile(cfgFile string) *CfgManager

func NewCfgManagerWithName

func NewCfgManagerWithName(path string, name string) *CfgManager

func (*CfgManager) Config

func (cm *CfgManager) Config() (*Config, error)

Config get current used config

func (*CfgManager) Load

func (cm *CfgManager) Load(migrations ...CfgMigrate) (*Config, error)

Load the config file and will create default if config file no exist Load the config file and will create default if config file no exist

func (*CfgManager) ParseDataDir

func (cm *CfgManager) ParseDataDir() (string, error)

ParseDataDir parse dataDir from config file

func (*CfgManager) Save

func (cm *CfgManager) Save(data ...interface{}) error

Save write config to file

type CfgMigrate

type CfgMigrate interface {
	Migration(cfg []byte, version int) ([]byte, int, error)
	StartVersion() int
	EndVersion() int
}

type Config

type Config struct {
	Version  int           `json:"version"`
	DataDir  string        `json:"dataDir"`
	LogLevel string        `json:"logLevel"` //info,warn,debug.
	ChainUrl string        `json:"chainUrl"` //chain url.
	FakeMode bool          `json:"fakeMode"` //fake mode for sonata
	RPC      RPCConfig     `json:"rpc"`
	Partners []*PartnerCfg `json:"partners"`
	Privacy  PrivacyCfg    `json:"privacy"`
}

func DefaultConfig

func DefaultConfig(dir string) (*Config, error)

func (*Config) LogDir

func (c *Config) LogDir() string

type PartnerCfg

type PartnerCfg struct {
	Name      string `json:"name"`
	ID        string `json:"id"`
	SonataUrl string `json:"sonataUrl"`
	Username  string `json:"username"`
	Password  string `json:"password"`
}

type PrivacyCfg

type PrivacyCfg struct {
	Enable         bool     `json:"enabled"`
	From           string   `json:"from"`
	For            []string `json:"for"`
	PrivateGroupID string   `json:"privateGroupID"`
}

type RPCConfig

type RPCConfig struct {
	Enable bool `json:"enabled"`

	// TCP or UNIX socket address for the RPC server to listen on
	ListenAddress string `json:"listenAddress"`

	// TCP or UNIX socket address for the gRPC server to listen on
	GRPCListenAddress  string   `json:"gRPCListenAddress"`
	CORSAllowedOrigins []string `json:"httpCors"`
}

Jump to

Keyboard shortcuts

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