Documentation ¶
Overview ¶
Package rkzero an implementation of rkentry.Entry which could be used start restful server with go-zero framework
Index ¶
- Constants
- func RegisterZeroEntryYAML(raw []byte) map[string]rkentry.Entry
- type BootZero
- type ZeroEntry
- func (entry *ZeroEntry) AddMiddleware(inters ...rest.Middleware)
- func (entry *ZeroEntry) Bootstrap(ctx context.Context)
- func (entry *ZeroEntry) GetDescription() string
- func (entry *ZeroEntry) GetName() string
- func (entry *ZeroEntry) GetType() string
- func (entry *ZeroEntry) Interrupt(ctx context.Context)
- func (entry *ZeroEntry) IsCommonServiceEnabled() bool
- func (entry *ZeroEntry) IsDocsEnabled() bool
- func (entry *ZeroEntry) IsPromEnabled() bool
- func (entry *ZeroEntry) IsStaticFileHandlerEnabled() bool
- func (entry *ZeroEntry) IsSwEnabled() bool
- func (entry *ZeroEntry) IsTlsEnabled() bool
- func (entry *ZeroEntry) MarshalJSON() ([]byte, error)
- func (entry *ZeroEntry) String() string
- func (entry *ZeroEntry) UnmarshalJSON([]byte) error
- type ZeroEntryOption
- func WithCertEntry(certEntry *rkentry.CertEntry) ZeroEntryOption
- func WithCommonServiceEntry(commonServiceEntry *rkentry.CommonServiceEntry) ZeroEntryOption
- func WithDescription(description string) ZeroEntryOption
- func WithDocsEntry(docsEntry *rkentry.DocsEntry) ZeroEntryOption
- func WithEventEntry(eventLogger *rkentry.EventEntry) ZeroEntryOption
- func WithLoggerEntry(logger *rkentry.LoggerEntry) ZeroEntryOption
- func WithMiddlewares(inters ...rest.Middleware) ZeroEntryOption
- func WithName(name string) ZeroEntryOption
- func WithPort(port uint64) ZeroEntryOption
- func WithPromEntry(prom *rkentry.PromEntry) ZeroEntryOption
- func WithServerConf(conf *rest.RestConf) ZeroEntryOption
- func WithServerRunOption(opts ...rest.RunOption) ZeroEntryOption
- func WithStaticFileHandlerEntry(static *rkentry.StaticFileHandlerEntry) ZeroEntryOption
- func WithSwEntry(sw *rkentry.SWEntry) ZeroEntryOption
Constants ¶
const (
// ZeroEntryType type of entry
ZeroEntryType = "ZeroEntry"
)
Variables ¶
This section is empty.
Functions ¶
func RegisterZeroEntryYAML ¶
RegisterZeroEntryYAML register zero entries with provided config file (Must YAML file).
Currently, support two ways to provide config file path. 1: With function parameters 2: With command line flag "--rkboot" described in rkcommon.BootConfigPathFlagKey (Will override function parameter if exists) Command line flag has high priority which would override function parameter
Error handling: Process will shutdown if any errors occur with rkcommon.ShutdownWithError function
Override elements in config file: We learned from HELM source code which would override elements in YAML file with "--set" flag followed with comma separated key/value pairs.
We are using "--rkset" described in rkcommon.BootConfigOverrideKey in order to distinguish with user flags Example of common usage: ./binary_file --rkset "key1=val1,key2=val2" Example of nested map: ./binary_file --rkset "outer.inner.key=val" Example of slice: ./binary_file --rkset "outer[0].key=val"
Types ¶
type BootZero ¶
type BootZero struct { Zero []struct { Enabled bool `yaml:"enabled" json:"enabled"` Name string `yaml:"name" json:"name"` Port uint64 `yaml:"port" json:"port"` Description string `yaml:"description" json:"description"` CertEntry string `yaml:"certEntry" json:"certEntry"` LoggerEntry string `yaml:"loggerEntry" json:"loggerEntry"` EventEntry string `yaml:"eventEntry" json:"eventEntry"` SW rkentry.BootSW `yaml:"sw" json:"sw"` Docs rkentry.BootDocs `yaml:"docs" json:"docs"` CommonService rkentry.BootCommonService `yaml:"commonService" json:"commonService"` Prom rkentry.BootProm `yaml:"prom" json:"prom"` Static rkentry.BootStaticFileHandler `yaml:"static" json:"static"` Middleware struct { Ignore []string `yaml:"ignore" json:"ignore"` Logging rkmidlog.BootConfig `yaml:"logging" json:"logging"` Prom rkmidprom.BootConfig `yaml:"prom" json:"prom"` Auth rkmidauth.BootConfig `yaml:"auth" json:"auth"` Cors rkmidcors.BootConfig `yaml:"cors" json:"cors"` Meta rkmidmeta.BootConfig `yaml:"meta" json:"meta"` Jwt rkmidjwt.BootConfig `yaml:"jwt" json:"jwt"` Secure rkmidsec.BootConfig `yaml:"secure" json:"secure"` RateLimit rkmidlimit.BootConfig `yaml:"rateLimit" json:"rateLimit"` Csrf rkmidcsrf.BootConfig `yaml:"csrf" yaml:"csrf"` Trace rkmidtrace.BootConfig `yaml:"trace" json:"trace"` } `yaml:"middleware" json:"middleware"` } `yaml:"zero" json:"zero"` }
BootZero boot config which is for zero entry.
type ZeroEntry ¶
type ZeroEntry struct { LoggerEntry *rkentry.LoggerEntry `json:"-" yaml:"-"` EventEntry *rkentry.EventEntry `json:"-" yaml:"-"` Port uint64 `json:"port" yaml:"port"` CertEntry *rkentry.CertEntry `json:"-" yaml:"-"` SwEntry *rkentry.SWEntry `json:"-" yaml:"-"` DocsEntry *rkentry.DocsEntry `json:"-" yaml:"-"` CommonServiceEntry *rkentry.CommonServiceEntry `json:"-" yaml:"-"` PromEntry *rkentry.PromEntry `json:"-" yaml:"-"` StaticFileEntry *rkentry.StaticFileHandlerEntry `json:"-" yaml:"-"` Server *rest.Server `json:"-" yaml:"-"` ServerConf *rest.RestConf `json:"-" yaml:"-"` ServerRunOption []rest.RunOption `json:"-" yaml:"-"` TlsConfig *tls.Config `json:"-" yaml:"-"` Middlewares []rest.Middleware `json:"-" yaml:"-"` // contains filtered or unexported fields }
ZeroEntry implements rkentry.Entry interface.
func GetZeroEntry ¶
GetZeroEntry Get ZeroEntry from rkentry.GlobalAppCtx.
func RegisterZeroEntry ¶
func RegisterZeroEntry(opts ...ZeroEntryOption) *ZeroEntry
RegisterZeroEntry register ZeroEntry with options.
func (*ZeroEntry) AddMiddleware ¶
func (entry *ZeroEntry) AddMiddleware(inters ...rest.Middleware)
AddMiddleware Add interceptors. This function should be called before Bootstrap() called.
func (*ZeroEntry) GetDescription ¶
GetDescription Get description of entry.
func (*ZeroEntry) IsCommonServiceEnabled ¶
IsCommonServiceEnabled Is common service entry enabled?
func (*ZeroEntry) IsDocsEnabled ¶
IsDocsEnabled Is TV entry enabled?
func (*ZeroEntry) IsPromEnabled ¶
IsPromEnabled Is prometheus entry enabled?
func (*ZeroEntry) IsStaticFileHandlerEnabled ¶
IsStaticFileHandlerEnabled Is static file handler entry enabled?
func (*ZeroEntry) IsSwEnabled ¶
IsSwEnabled Is swagger entry enabled?
func (*ZeroEntry) IsTlsEnabled ¶
IsTlsEnabled Is TLS enabled?
func (*ZeroEntry) MarshalJSON ¶
MarshalJSON Marshal entry.
func (*ZeroEntry) UnmarshalJSON ¶
UnmarshalJSON Not supported.
type ZeroEntryOption ¶
type ZeroEntryOption func(*ZeroEntry)
ZeroEntryOption zero entry option.
func WithCertEntry ¶
func WithCertEntry(certEntry *rkentry.CertEntry) ZeroEntryOption
WithCertEntry provide rkentry.CertEntry.
func WithCommonServiceEntry ¶
func WithCommonServiceEntry(commonServiceEntry *rkentry.CommonServiceEntry) ZeroEntryOption
WithCommonServiceEntry provide CommonServiceEntry.
func WithDescription ¶
func WithDescription(description string) ZeroEntryOption
WithDescription provide name.
func WithDocsEntry ¶
func WithDocsEntry(docsEntry *rkentry.DocsEntry) ZeroEntryOption
WithDocsEntry provide TvEntry.
func WithEventEntry ¶
func WithEventEntry(eventLogger *rkentry.EventEntry) ZeroEntryOption
WithEventEntry provide rkentry.EventEntry.
func WithLoggerEntry ¶
func WithLoggerEntry(logger *rkentry.LoggerEntry) ZeroEntryOption
WithLoggerEntry provide rkentry.LoggerEntry.
func WithMiddlewares ¶
func WithMiddlewares(inters ...rest.Middleware) ZeroEntryOption
WithMiddlewares provide user middlewares.
func WithPromEntry ¶
func WithPromEntry(prom *rkentry.PromEntry) ZeroEntryOption
WithPromEntry provide PromEntry.
func WithServerConf ¶
func WithServerConf(conf *rest.RestConf) ZeroEntryOption
WithServerConf provide *rest.RestConf.
func WithServerRunOption ¶
func WithServerRunOption(opts ...rest.RunOption) ZeroEntryOption
WithServerRunOption provide *rest.RestConf.
func WithStaticFileHandlerEntry ¶
func WithStaticFileHandlerEntry(static *rkentry.StaticFileHandlerEntry) ZeroEntryOption
WithStaticFileHandlerEntry provide CommonServiceEntry.
func WithSwEntry ¶
func WithSwEntry(sw *rkentry.SWEntry) ZeroEntryOption
WithSwEntry provide SwEntry.