config

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {

	// ConfigFile 配置文件路径,通过命令行设置
	ConfigFile string `json:"config,omitempty"`

	// LogConfigFile 日志配置文件路径,通过命令行设置
	LogConfigFile string `json:"log,omitempty"`

	// Consensus 中继共识配置,为了以后支持更多共识算法,添加次配置
	//    "no" - 不启用共识
	//    默认 - 2/3共识
	Consensus bool `json:"consensus,omitempty"`

	// EventWaitMillitime 交易事件被监听到后需要等待的事件,
	// <=0 不等待
	// >0 等待相应毫秒数
	EventWaitMillitime int64 `json:"eventWaitMillitime,omitempty"`

	// Prikey Cassini relay's private key
	Prikey string `json:"prikey,omitempty"`

	// Nats 集群配置,以逗号分割
	Nats string `json:"nats,omitempty"`

	// Kafka 集群配置,以逗号分割
	Kafka string `json:"kafka,omitempty"`

	// Mocks 所有需要Mock的服务配置
	Mocks []*MockConfig `json:"mocks,omitempty"`

	// Qscs 与relay连接的区块链相关配置
	Qscs []*QscConfig `json:"qscs,omitempty"`

	// UseEtcd Whether to use etcd or not
	UseEtcd bool `json:"useEtcd,omitempty"`

	// Lock config the lock
	//
	// "etcd://192.168.1.100:2379,192.168.1.101:2379,192.168.1.102:2379"
	Lock string `json:"lock,omitempty"`

	// LockTTL timeout for lock
	//
	// 5 - the lock will be auto-unlock with 5s when lose session
	LockTTL int `json:"lockTTL,omitempty"`

	// EmbedEtcd Whether to start embed etcd or not
	EmbedEtcd bool `json:"embedEtcd,omitempty"`

	// Etcd Embed-etcd config
	Etcd *EtcdConfig `json:"etcd,omitempty"`
}

Config 封装配置数据

func CreateConfig

func CreateConfig(bytes []byte) (*Config, error)

CreateConfig 根据传入数据创建配置

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a default configuration for a Tendermint node

func GetConfig

func GetConfig() *Config

GetConfig 获取配置数据

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig 读取配置数据

func TestConfig

func TestConfig() *Config

TestConfig returns a configuration that can be used for testing

func (*Config) GetQscConfig

func (c *Config) GetQscConfig(chainID string) (qsc QscConfig)

GetQscConfig 获取指定 ChainID 的 QSC 配置

type EtcdConfig added in v0.0.3

type EtcdConfig struct {

	// Name - human-readable name for this member.
	//
	// --name 'default'
	Name string `json:"name,omitempty"`

	// Listen - list of URLs to listen on for client traffic.
	//
	// --listen-client-urls 'http://localhost:2379'
	Listen string `json:"listen,omitempty"`

	// Advertise list of this member's client URLs to advertise to the public.
	// The client URLs advertised should be accessible to machines that talk to etcd cluster. etcd client libraries parse these URLs to connect to the cluster.
	//
	// --advertise-client-urls http://localhost:2379
	Advertise string `json:"advertise,omitempty"`

	// ListenPeer list of URLs to listen on for peer traffic.
	//
	// --listen-peer-urls http://localhost:2380
	ListenPeer string `json:"listenPeer,omitempty"`

	// AdvertisePeer list of this member's peer URLs to advertise to the rest of the cluster.
	//
	// --initial-advertise-peer-urls http://localhost:2380
	AdvertisePeer string `json:"advertisePeer,omitempty"`

	// ClusterToken initial cluster token for the etcd cluster during bootstrap.
	// Specifying this can protect you from unintended cross-cluster interaction when running multiple clusters.
	//
	// --initial-cluster-token etcd-cluster
	ClusterToken string `json:"clusterToken,omitempty"`

	// Cluster initial cluster configuration for bootstrapping.
	//
	// --initial-cluster 'default=http://localhost:2380'
	Cluster string `json:"cluster,omitempty"`
}

EtcdConfig Embed-etcd config

type MockConfig

type MockConfig struct {

	// Name 链名称,mock 时,交易事件的qcp.from
	Name string `json:"name,omitempty"`

	// To 目标链名称,mock 时,交易事件的qcp.to
	To string `json:"to,omitempty"`

	// Subscribe 交易事件订阅条件,为空时通过To 参数自动拼装
	Subscribe string `json:"subscribe,omitempty"`

	// Sequence 交易序列号
	Sequence int64 `json:"sequence,omitempty"`

	// RPC RPC相关配置
	RPC *RPCConfig `json:"rpc,omitempty"`
}

MockConfig 封装 Mock 配置数据

func TestQscMockConfig

func TestQscMockConfig() *MockConfig

TestQscMockConfig 创建Qsc Mock 测试配置

type QscConfig

type QscConfig struct {
	// Name 链名称
	Name string `json:"name,omitempty"`

	// Signature if need sign tx data for this chain
	// true - required
	// false/default - not required
	Signature bool `json:"signature,omitempty"`

	// Pubkey 链的公钥
	Pubkey string `json:"pubkey,omitempty"`

	// Certificate 链给relay颁发的证书文件
	Certificate string `json:"certificate,omitempty"`

	// NodeAddress 区块链节点地址,多个之间用“,”分割
	NodeAddress string `json:"nodes,omitempty"`
}

QscConfig qsc 配置封装

func DefaultQscConfig

func DefaultQscConfig() []*QscConfig

DefaultQscConfig 创建默认配置

func TestQscConfig

func TestQscConfig() []*QscConfig

TestQscConfig 创建测试配置

type RPCConfig

type RPCConfig struct {
	// 监听地址端口
	NodeAddress string `json:"nodes,omitempty"`
}

RPCConfig 相关配置

Jump to

Keyboard shortcuts

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