Documentation
¶
Overview ¶
Package config provides configuration-related capabilities for this project.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var SupportValidate = map[string]bool{ "go": true, }
SupportValidate defines whether a certain language supports validation. Validation code will be generated only when: 1. The language appears as a key in this map. 2. The corresponding value is true.
var TRPCCliVersion = "v1.0.9"
TRPCCliVersion is the version of trpc-cmdline tool.
Functions ¶
func CurrentTemplatePath ¶
CurrentTemplatePath gets the installation path of the trpc configuration file, which is installed to $HOME/.trpc-cmdline-assets.
func Init ¶
Init initializes the configuration. If the configuration file trpc.yaml is missing, or the code template is missing, or the configuration version does not match, the configuration is automatically installed. After the initialization is successful, returns the path of config file's directory.
func SetupDependencies ¶
func SetupDependencies(deps []*Dependency) error
SetupDependencies configures dependency installation.
Types ¶
type Config ¶
type Config struct { Domain string `yaml:"domain"` // host in importPath TplFileExt string `yaml:"tpl_file_ext"` IDL map[string]*Dependency `yaml:"idl"` // IDL name -> IDL tool Tools map[string][]*Dependency `yaml:"tools"` // Programming language -> Dependency tools Plugins map[string][]string `yaml:"plugins"` // Programming language -> Dependency plugins Templates map[string]map[string]*Template `yaml:"templates"` // idltype -> Code templates for each language }
Config is the global config.
type Dependency ¶
type Dependency struct { Executable string `yaml:"executable"` // Executable file name. VersionMin string `yaml:"version_min"` // Min version. VersionCmd string `yaml:"version_cmd"` // Max version. ArtifactURL string `yaml:"artifact_url"` // Artifact download URL. Repository string `yaml:"repository"` // Repository URL. MD5 string `yaml:"md5"` // md5 sum up. Fallback string `yaml:"fallback"` // Failure prompt. }
Dependency is the description of dependencies.
func LoadDependencies ¶
func LoadDependencies(languages ...string) ([]*Dependency, error)
LoadDependencies loads the configuration on demand based on the given language type.
func (*Dependency) CheckVersion ¶
func (d *Dependency) CheckVersion() (passed bool, error error)
CheckVersion check if installed version meet the version requirement.
func (*Dependency) Installed ¶
func (d *Dependency) Installed() bool
Installed checks installed or not.
func (*Dependency) TryInstallTo ¶
func (d *Dependency) TryInstallTo(path string) error
TryInstallTo tries to install the dependency to the given path.
type IDLType ¶
type IDLType uint
IDLType is IDL type.
const ( IDLTypeProtobuf IDLType = iota // IDL is protobuf IDLTypeFlatBuffers // IDL is flatbuffers IDLTypeInvalid )
Related constants of IDL type.
type LanguageTemplates ¶
LanguageTemplates is the templates for each programming language.
type Template ¶
type Template struct { Language string `yaml:"language"` // Programming language LangFileExt string `yaml:"lang_file_ext"` // Source file extension for the programming language // The output filename for the stub corresponds to: service name + separator + original file name Separator string `yaml:"separator"` // Keep the original file name as a suffix for the generated files KeepOrigName bool `yaml:"keep_orig_name"` // Follow the camelcase style for generated file names CamelCaseName bool `yaml:"camelcase_name"` AssetDir string `yaml:"asset_dir"` // Code template directory RPCServerStub string `yaml:"rpc_server_stub"` // Server stub RPCServerTestStub string `yaml:"rpc_server_test_stub"` // Server test stub RPCClientStub []string `yaml:"rpc_client_stub"` // Client stub // Whether the client stub includes all service definitions RPCClientStubPerService bool `yaml:"rpc_client_stub_per_service"` }
Template is language templates.