rkzero

package
v1.2.18 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: Apache-2.0 Imports: 40 Imported by: 4

Documentation

Overview

Package rkzero an implementation of rkentry.Entry which could be used start restful server with go-zero framework

Index

Constants

View Source
const (
	// ZeroEntryType type of entry
	ZeroEntryType = "ZeroEntry"
)

Variables

This section is empty.

Functions

func RegisterZeroEntryYAML added in v1.0.0

func RegisterZeroEntryYAML(raw []byte) map[string]rkentry.Entry

RegisterZeroEntryYAML register zero entries with provided config file (Must YAML file).

Currently, support two ways to provide config file filepath. 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 added in v1.0.0

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"`
		PProf         rkentry.BootPProf             `yaml:"pprof" json:"pprof"`
		Middleware    struct {
			Ignore     []string              `yaml:"ignore" json:"ignore"`
			ErrorModel string                `yaml:"errorModel" json:"errorModel"`
			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:"-"`
	PProfEntry         *rkentry.PProfEntry             `json:"-" yaml:"-"`
	Middlewares        []rest.Middleware               `json:"-" yaml:"-"`
	// contains filtered or unexported fields
}

ZeroEntry implements rkentry.Entry interface.

func GetZeroEntry

func GetZeroEntry(name string) *ZeroEntry

GetZeroEntry Get ZeroEntry from rkentry.GlobalAppCtx.

func RegisterZeroEntry

func RegisterZeroEntry(opts ...ZeroEntryOption) *ZeroEntry

RegisterZeroEntry register ZeroEntry with options.

func (*ZeroEntry) AddMiddleware added in v1.0.0

func (entry *ZeroEntry) AddMiddleware(inters ...rest.Middleware)

AddMiddleware Add interceptors. This function should be called before Bootstrap() called.

func (*ZeroEntry) Bootstrap

func (entry *ZeroEntry) Bootstrap(ctx context.Context)

Bootstrap ZeroEntry.

func (*ZeroEntry) GetDescription

func (entry *ZeroEntry) GetDescription() string

GetDescription Get description of entry.

func (*ZeroEntry) GetName

func (entry *ZeroEntry) GetName() string

GetName Get entry name.

func (*ZeroEntry) GetType

func (entry *ZeroEntry) GetType() string

GetType Get entry type.

func (*ZeroEntry) Interrupt

func (entry *ZeroEntry) Interrupt(ctx context.Context)

Interrupt ZeroEntry.

func (*ZeroEntry) IsCommonServiceEnabled

func (entry *ZeroEntry) IsCommonServiceEnabled() bool

IsCommonServiceEnabled Is common service entry enabled?

func (*ZeroEntry) IsDocsEnabled added in v1.0.0

func (entry *ZeroEntry) IsDocsEnabled() bool

IsDocsEnabled Is TV entry enabled?

func (*ZeroEntry) IsPProfEnabled added in v1.1.0

func (entry *ZeroEntry) IsPProfEnabled() bool

IsPProfEnabled Is pprof entry enabled?

func (*ZeroEntry) IsPromEnabled

func (entry *ZeroEntry) IsPromEnabled() bool

IsPromEnabled Is prometheus entry enabled?

func (*ZeroEntry) IsStaticFileHandlerEnabled added in v1.0.0

func (entry *ZeroEntry) IsStaticFileHandlerEnabled() bool

IsStaticFileHandlerEnabled Is static file handler entry enabled?

func (*ZeroEntry) IsSwEnabled

func (entry *ZeroEntry) IsSwEnabled() bool

IsSwEnabled Is swagger entry enabled?

func (*ZeroEntry) IsTlsEnabled

func (entry *ZeroEntry) IsTlsEnabled() bool

IsTlsEnabled Is TLS enabled?

func (*ZeroEntry) MarshalJSON

func (entry *ZeroEntry) MarshalJSON() ([]byte, error)

MarshalJSON Marshal entry.

func (*ZeroEntry) String

func (entry *ZeroEntry) String() string

String Stringfy entry.

func (*ZeroEntry) UnmarshalJSON

func (entry *ZeroEntry) UnmarshalJSON([]byte) error

UnmarshalJSON Not supported.

type ZeroEntryOption

type ZeroEntryOption func(*ZeroEntry)

ZeroEntryOption zero entry option.

func WithCertEntry added in v0.0.3

func WithCertEntry(certEntry *rkentry.CertEntry) ZeroEntryOption

WithCertEntry provide rkentry.CertEntry.

func WithCommonServiceEntry added in v0.0.3

func WithCommonServiceEntry(commonServiceEntry *rkentry.CommonServiceEntry) ZeroEntryOption

WithCommonServiceEntry provide CommonServiceEntry.

func WithDescription added in v0.0.3

func WithDescription(description string) ZeroEntryOption

WithDescription provide name.

func WithDocsEntry added in v1.0.0

func WithDocsEntry(docsEntry *rkentry.DocsEntry) ZeroEntryOption

WithDocsEntry provide TvEntry.

func WithEventEntry added in v1.0.0

func WithEventEntry(eventLogger *rkentry.EventEntry) ZeroEntryOption

WithEventEntry provide rkentry.EventEntry.

func WithLoggerEntry added in v1.0.0

func WithLoggerEntry(logger *rkentry.LoggerEntry) ZeroEntryOption

WithLoggerEntry provide rkentry.LoggerEntry.

func WithMiddlewares added in v1.0.0

func WithMiddlewares(inters ...rest.Middleware) ZeroEntryOption

WithMiddlewares provide user middlewares.

func WithName added in v0.0.3

func WithName(name string) ZeroEntryOption

WithName provide name.

func WithPProfEntry added in v1.1.0

func WithPProfEntry(p *rkentry.PProfEntry) ZeroEntryOption

WithPProfEntry provide rkentry.PProfEntry.

func WithPort added in v0.0.3

func WithPort(port uint64) ZeroEntryOption

WithPort provide port.

func WithPromEntry added in v0.0.3

func WithPromEntry(prom *rkentry.PromEntry) ZeroEntryOption

WithPromEntry provide PromEntry.

func WithServerConf added in v0.0.3

func WithServerConf(conf *rest.RestConf) ZeroEntryOption

WithServerConf provide *rest.RestConf.

func WithServerRunOption

func WithServerRunOption(opts ...rest.RunOption) ZeroEntryOption

WithServerRunOption provide *rest.RestConf.

func WithStaticFileHandlerEntry added in v1.0.0

func WithStaticFileHandlerEntry(static *rkentry.StaticFileHandlerEntry) ZeroEntryOption

WithStaticFileHandlerEntry provide CommonServiceEntry.

func WithSwEntry added in v0.0.3

func WithSwEntry(sw *rkentry.SWEntry) ZeroEntryOption

WithSwEntry provide SwEntry.

Jump to

Keyboard shortcuts

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