config_generator

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Config_Addr_DEFAULT string

Functions

This section is empty.

Types

type Config

type Config struct {
	ServiceName   string       `thrift:"ServiceName,1" json:"ServiceName"`
	SubConfigList []*SubConfig `thrift:"SubConfigList,2" json:"SubConfigList"`
	Addr          *string      `thrift:"addr,3,optional" json:"addr,omitempty"`
}

func NewConfig

func NewConfig() *Config

func (*Config) GetAddr

func (p *Config) GetAddr() (v string)

func (*Config) GetServiceName

func (p *Config) GetServiceName() (v string)

func (*Config) GetSubConfigList

func (p *Config) GetSubConfigList() (v []*SubConfig)

func (*Config) InitDefault

func (p *Config) InitDefault()

func (*Config) IsSetAddr

func (p *Config) IsSetAddr() bool

func (*Config) Read

func (p *Config) Read(iprot thrift.TProtocol) (err error)

func (*Config) ReadField1

func (p *Config) ReadField1(iprot thrift.TProtocol) error

func (*Config) ReadField2

func (p *Config) ReadField2(iprot thrift.TProtocol) error

func (*Config) ReadField3

func (p *Config) ReadField3(iprot thrift.TProtocol) error

func (*Config) String

func (p *Config) String() string

func (*Config) Write

func (p *Config) Write(oprot thrift.TProtocol) (err error)

type ConfigGenerateMeta

type ConfigGenerateMeta struct {
	Desc            string          `json:"desc,omitempty"`
	Kind            string          `json:"kind,omitempty"`
	ConfigStruct    Struct          `json:"config_struct,omitempty"`
	ConfigValueType ConfigValueType `json:"config_value_type,omitempty"`
	Key             string          `json:"key,omitempty"`
	// contains filtered or unexported fields
}

type ConfigKvPair

type ConfigKvPair struct {
	Key       string          `thrift:"Key,1" json:"Key"`
	Value     string          `thrift:"Value,2" json:"Value"`
	ValueType ConfigValueType `thrift:"ValueType,3" json:"ValueType"`
	Desc      string          `thrift:"Desc,4" json:"Desc"`
	Kind      string          `thrift:"kind,5" json:"kind"`
}

func NewConfigKvPair

func NewConfigKvPair() *ConfigKvPair

func (*ConfigKvPair) GetDesc

func (p *ConfigKvPair) GetDesc() (v string)

func (*ConfigKvPair) GetKey

func (p *ConfigKvPair) GetKey() (v string)

func (*ConfigKvPair) GetKind

func (p *ConfigKvPair) GetKind() (v string)

func (*ConfigKvPair) GetValue

func (p *ConfigKvPair) GetValue() (v string)

func (*ConfigKvPair) GetValueType

func (p *ConfigKvPair) GetValueType() (v ConfigValueType)

func (*ConfigKvPair) InitDefault

func (p *ConfigKvPair) InitDefault()

func (*ConfigKvPair) Read

func (p *ConfigKvPair) Read(iprot thrift.TProtocol) (err error)

func (*ConfigKvPair) ReadField1

func (p *ConfigKvPair) ReadField1(iprot thrift.TProtocol) error

func (*ConfigKvPair) ReadField2

func (p *ConfigKvPair) ReadField2(iprot thrift.TProtocol) error

func (*ConfigKvPair) ReadField3

func (p *ConfigKvPair) ReadField3(iprot thrift.TProtocol) error

func (*ConfigKvPair) ReadField4

func (p *ConfigKvPair) ReadField4(iprot thrift.TProtocol) error

func (*ConfigKvPair) ReadField5

func (p *ConfigKvPair) ReadField5(iprot thrift.TProtocol) error

func (*ConfigKvPair) String

func (p *ConfigKvPair) String() string

func (*ConfigKvPair) Write

func (p *ConfigKvPair) Write(oprot thrift.TProtocol) (err error)

type ConfigValueType

type ConfigValueType int64
const (
	ConfigValueType_JsonType ConfigValueType = 1
	ConfigValueType_YamlType ConfigValueType = 2
	ConfigValueType_XmlType  ConfigValueType = 3
	ConfigValueType_TextType ConfigValueType = 4
)

func ConfigValueTypeFromString

func ConfigValueTypeFromString(s string) (ConfigValueType, error)

func ConfigValueTypePtr

func ConfigValueTypePtr(v ConfigValueType) *ConfigValueType

func (*ConfigValueType) Scan

func (p *ConfigValueType) Scan(value interface{}) (err error)

func (ConfigValueType) String

func (p ConfigValueType) String() string

func (*ConfigValueType) Value

func (p *ConfigValueType) Value() (driver.Value, error)

type Field

type Field struct {
	FieldName   string     `json:"field_name,omitempty"` // FieldName of the field
	Value       string     `json:"value,omitempty"`      // Value of the field (used for primitive types)
	FieldType   string     `json:"field_type,omitempty"` // FieldType of the field
	IsStruct    bool       `json:"is_struct"`
	IsSlice     bool       `json:"is_slice"`
	IsBasicType bool       `json:"is_basic"`
	Tags        []FieldTag `json:"tags,omitempty"`
	Children    []Field    `json:"children,omitempty"`
}

type FieldTag

type FieldTag struct {
	TagKey   string `json:"tag_key"`   // eg: json
	TagValue string `json:"tag_value"` // eg: "name,omitempty"
}

type Result

type Result struct {
	ServiceName           string              `json:"service_name,omitempty"`
	Addr                  string              `json:"addr,omitempty"`
	SubConfigMetadataList []SubConfigMetadata `json:"sub_config_metadata_list,omitempty"`
}

func HandleRequest

func HandleRequest(req *Config) (*Result, error)

HandleRequest processes the configuration request and returns the result.

type Struct

type Struct struct {
	StructName string  `json:"struct_name,omitempty"`
	Fields     []Field `json:"fields,omitempty"`
}

Struct to store struct fields

type SubConfig

type SubConfig struct {
	NameSpace        string          `thrift:"NameSpace,1" json:"NameSpace"`
	ConfigKvPairList []*ConfigKvPair `thrift:"ConfigKvPairList,2" json:"ConfigKvPairList"`
}

func NewSubConfig

func NewSubConfig() *SubConfig

func (*SubConfig) GetConfigKvPairList

func (p *SubConfig) GetConfigKvPairList() (v []*ConfigKvPair)

func (*SubConfig) GetNameSpace

func (p *SubConfig) GetNameSpace() (v string)

func (*SubConfig) InitDefault

func (p *SubConfig) InitDefault()

func (*SubConfig) Read

func (p *SubConfig) Read(iprot thrift.TProtocol) (err error)

func (*SubConfig) ReadField1

func (p *SubConfig) ReadField1(iprot thrift.TProtocol) error

func (*SubConfig) ReadField2

func (p *SubConfig) ReadField2(iprot thrift.TProtocol) error

func (*SubConfig) String

func (p *SubConfig) String() string

func (*SubConfig) Write

func (p *SubConfig) Write(oprot thrift.TProtocol) (err error)

type SubConfigMetadata

type SubConfigMetadata struct {
	Namespace      string               `json:"namespace,omitempty"`
	ConfigMetadata []ConfigGenerateMeta `json:"config_metadata,omitempty"`
}

type Yaml2Go

type Yaml2Go struct {
	StructsMeta *ConfigGenerateMeta
	// contains filtered or unexported fields
}

Yaml2Go to store converted result

func New

func New(key, desc, kind string, configValueType ConfigValueType) Yaml2Go

New creates Yaml2Go object

func (*Yaml2Go) AppendResult

func (yg *Yaml2Go) AppendResult(structName, l string, s ...Struct)

AppendResult add lines to the result

func (*Yaml2Go) Convert

func (yg *Yaml2Go) Convert(structName string, data []byte) (string, error)

Convert transforms map[string]interface{} to go struct

func (*Yaml2Go) NewStruct

func (yg *Yaml2Go) NewStruct(structName, parent string) string

NewStruct creates new entry in structMap result

func (*Yaml2Go) Structify

func (yg *Yaml2Go) Structify(structName, k string, v interface{}, arrayElem bool)

Structify transforms map key values to struct fields structName : parent struct name k, v : fields in the struct

Jump to

Keyboard shortcuts

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