Documentation
¶
Overview ¶
Package types defines universal types for configuration +genx:doc
Code generated by genx:doc DO NOT EDIT.
Index ¶
- Constants
- Variables
- func CanBeInitialized(initializer any) bool
- func Close(closable any) error
- func CloseByContext(ctx context.Context, closable any) error
- func Init(initializer any) error
- func InitByContext(ctx context.Context, initializer any) error
- func IsClosable(closable any) bool
- func Span() func() time.Duration
- type CanShutdown
- type Defaulter
- type Duration
- type Endpoint
- func (e *Endpoint[Option]) AddOption(k string, vs ...string)
- func (v *Endpoint[Option]) DocOf(names ...string) ([]string, bool)
- func (e *Endpoint[Option]) Init() (err error)
- func (e *Endpoint[Option]) IsZero() bool
- func (e *Endpoint[Option]) Key() string
- func (e *Endpoint[Option]) LivenessCheck(ctx context.Context) (v liveness.Result)
- func (e *Endpoint[Option]) Scheme() string
- func (e *Endpoint[Option]) SecurityString() string
- func (e *Endpoint[Option]) SetDefault()
- func (e *Endpoint[Option]) String() string
- func (e *Endpoint[Option]) URL() url.URL
- type EndpointNoOption
- type Password
- type Runner
- type Userinfo
Examples ¶
Constants ¶
View Source
const ( TARGET_PROJECT = "PROJECT" DEPLOY_ENVIRONMENT = "DEPLOY_ENVIRONMENT" )
View Source
const MaskedPassword = "--------"
Variables ¶
View Source
var ErrInvalidClosableValue = errors.New("invalid closable")
View Source
var ErrInvalidInitializerValue = errors.New("invalid initializer")
Functions ¶
func CanBeInitialized ¶ added in v0.4.1
func IsClosable ¶ added in v0.4.1
Types ¶
type CanShutdown ¶ added in v0.4.1
type Duration ¶ added in v0.2.5
Duration extends time.Duraiton for
func (Duration) MarshalText ¶ added in v0.2.5
func (*Duration) UnmarshalText ¶ added in v0.2.5
type Endpoint ¶
type Endpoint[Option any] struct { // Address component connection endpoint address Address string // ExtraAddress for cluster multi-endpoint ExtraAddress []string // Auth support Endpoint auth info with username and password Auth Userinfo // Option component Option. if no option use EndpointNoOption Option Option // Cert X509KeyPair to support certification info Cert conftls.X509KeyPair // contains filtered or unexported fields }
Endpoint a connectable endpoint Note options in url Param can override option
Example ¶
grp := envx.NewGroup("TEST")
enc := envx.NewEncoder(grp)
err := enc.Encode(types.Endpoint[MockOption]{
Address: "redis://localhost:6379/1",
Auth: types.Userinfo{Username: "username", Password: "LelzsnHN2xnJd/MB+JGIXWqd8pJPhPYfuRfDbrCsZE8="},
Option: MockOption{},
Cert: conftls.X509KeyPair{
Key: "key_path",
Crt: "crt_path",
CA: "ca_path",
},
})
if err != nil {
return
}
// for configuration
fmt.Println(string(grp.Bytes()))
fmt.Println(string(grp.MaskBytes()))
Output: TEST__Address=redis://localhost:6379/1 TEST__Auth_DecryptKeyEnv= TEST__Auth_Password=LelzsnHN2xnJd/MB+JGIXWqd8pJPhPYfuRfDbrCsZE8= TEST__Auth_Username=username TEST__Cert_CA=ca_path TEST__Cert_Crt=crt_path TEST__Cert_Key=key_path TEST__Option_Name= TEST__Option_Timeout=0s TEST__Address=redis://localhost:6379/1 TEST__Auth_DecryptKeyEnv= TEST__Auth_Password=-------- TEST__Auth_Username=username TEST__Cert_CA=ca_path TEST__Cert_Crt=crt_path TEST__Cert_Key=key_path TEST__Option_Name= TEST__Option_Timeout=0s
func (*Endpoint[Option]) Key ¶
Key returns Scheme, Host and Path. this method helps to identify a unique component
func (*Endpoint[Option]) LivenessCheck ¶ added in v0.2.6
func (*Endpoint[Option]) SecurityString ¶
SecurityString like String but auth info is hidden
func (*Endpoint[Option]) SetDefault ¶ added in v0.2.18
func (e *Endpoint[Option]) SetDefault()
type EndpointNoOption ¶ added in v0.2.6
type EndpointNoOption = Endpoint[struct{}]
type Password ¶
type Password string
Password as a string underlying and implements SecurityStringer
func (Password) SecurityString ¶
type Userinfo ¶ added in v0.2.6
type Userinfo struct {
Username string
Password Password
// DecryptKeyEnv if not empty read key from env and decrypt password by AEC
// with ECB mode and PKCS7 padding. default env key is PASSWORD_DEC_KEY
DecryptKeyEnv string
}
Userinfo likes url.Userinfo but embed aes decryptor if DecryptKeyEnv is set. and implemented SecurityString to hide password
func (Userinfo) SecurityString ¶ added in v0.2.6
func (*Userinfo) SetDefault ¶ added in v0.2.6
func (u *Userinfo) SetDefault()
Source Files
¶
Click to show internal directories.
Click to hide internal directories.