Documentation
¶
Overview ¶
Copyright (c) 2021 rookie-ninja
Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Copyright (c) 2021 rookie-ninja ¶
Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Copyright (c) 2021 rookie-ninja ¶
Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Copyright (c) 2021 rookie-ninja ¶
Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Copyright (c) 2021 rookie-ninja ¶
Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Index ¶
- Constants
- Variables
- func RegisterGinEntriesWithConfig(configFilePath string) map[string]rkentry.Entry
- type BootConfigCommonService
- type BootConfigGin
- type BootConfigProm
- type BootConfigSw
- type BootConfigTv
- type CommonServiceEntry
- func (entry *CommonServiceEntry) Apis(ctx *gin.Context)
- func (entry *CommonServiceEntry) Bootstrap(ctx context.Context)
- func (entry *CommonServiceEntry) Certs(ctx *gin.Context)
- func (entry *CommonServiceEntry) Configs(ctx *gin.Context)
- func (entry *CommonServiceEntry) Deps(ctx *gin.Context)
- func (entry *CommonServiceEntry) Entries(ctx *gin.Context)
- func (entry *CommonServiceEntry) Gc(ctx *gin.Context)
- func (entry *CommonServiceEntry) GetDescription() string
- func (entry *CommonServiceEntry) GetName() string
- func (entry *CommonServiceEntry) GetType() string
- func (entry *CommonServiceEntry) Git(ctx *gin.Context)
- func (entry *CommonServiceEntry) Healthy(ctx *gin.Context)
- func (entry *CommonServiceEntry) Info(ctx *gin.Context)
- func (entry *CommonServiceEntry) Interrupt(ctx context.Context)
- func (entry *CommonServiceEntry) License(ctx *gin.Context)
- func (entry *CommonServiceEntry) Logs(ctx *gin.Context)
- func (entry *CommonServiceEntry) MarshalJSON() ([]byte, error)
- func (entry *CommonServiceEntry) Readme(ctx *gin.Context)
- func (entry *CommonServiceEntry) Req(ctx *gin.Context)
- func (entry *CommonServiceEntry) String() string
- func (entry *CommonServiceEntry) Sys(ctx *gin.Context)
- func (entry *CommonServiceEntry) UnmarshalJSON([]byte) error
- type CommonServiceEntryOption
- type GinEntry
- func (entry *GinEntry) AddInterceptor(inters ...gin.HandlerFunc)
- func (entry *GinEntry) Bootstrap(ctx context.Context)
- func (entry *GinEntry) GetDescription() string
- func (entry *GinEntry) GetName() string
- func (entry *GinEntry) GetType() string
- func (entry *GinEntry) Interrupt(ctx context.Context)
- func (entry *GinEntry) IsCommonServiceEnabled() bool
- func (entry *GinEntry) IsPromEnabled() bool
- func (entry *GinEntry) IsSwEnabled() bool
- func (entry *GinEntry) IsTlsEnabled() bool
- func (entry *GinEntry) IsTvEnabled() bool
- func (entry *GinEntry) MarshalJSON() ([]byte, error)
- func (entry *GinEntry) RegisterInterceptor(interceptor gin.HandlerFunc)
- func (entry *GinEntry) String() string
- func (entry *GinEntry) UnmarshalJSON([]byte) error
- type GinEntryOption
- func WithCertEntryGin(certEntry *rkentry.CertEntry) GinEntryOption
- func WithCommonServiceEntryGin(commonServiceEntry *CommonServiceEntry) GinEntryOption
- func WithDescriptionGin(description string) GinEntryOption
- func WithEventLoggerEntryGin(eventLogger *rkentry.EventLoggerEntry) GinEntryOption
- func WithInterceptorsGin(inters ...gin.HandlerFunc) GinEntryOption
- func WithNameGin(name string) GinEntryOption
- func WithPortGin(port uint64) GinEntryOption
- func WithPromEntryGin(prom *PromEntry) GinEntryOption
- func WithSwEntryGin(sw *SwEntry) GinEntryOption
- func WithTVEntryGin(tvEntry *TvEntry) GinEntryOption
- func WithZapLoggerEntryGin(zapLogger *rkentry.ZapLoggerEntry) GinEntryOption
- type PromEntry
- func (entry *PromEntry) Bootstrap(ctx context.Context)
- func (entry *PromEntry) GetDescription() string
- func (entry *PromEntry) GetName() string
- func (entry *PromEntry) GetType() string
- func (entry *PromEntry) Interrupt(ctx context.Context)
- func (entry *PromEntry) MarshalJSON() ([]byte, error)
- func (entry *PromEntry) RegisterCollectors(collectors ...prometheus.Collector) error
- func (entry *PromEntry) String() string
- func (entry *PromEntry) UnmarshalJSON(b []byte) error
- type PromEntryOption
- func WithEventLoggerEntryProm(eventLoggerEntry *rkentry.EventLoggerEntry) PromEntryOption
- func WithNameProm(name string) PromEntryOption
- func WithPathProm(path string) PromEntryOption
- func WithPortProm(port uint64) PromEntryOption
- func WithPromRegistryProm(registry *prometheus.Registry) PromEntryOption
- func WithPusherProm(pusher *rkprom.PushGatewayPusher) PromEntryOption
- func WithZapLoggerEntryProm(zapLoggerEntry *rkentry.ZapLoggerEntry) PromEntryOption
- type SwEntry
- func (entry *SwEntry) AssetsFileHandler() gin.HandlerFunc
- func (entry *SwEntry) Bootstrap(ctx context.Context)
- func (entry *SwEntry) ConfigFileHandler() gin.HandlerFunc
- func (entry *SwEntry) GetDescription() string
- func (entry *SwEntry) GetName() string
- func (entry *SwEntry) GetType() string
- func (entry *SwEntry) Interrupt(ctx context.Context)
- func (entry *SwEntry) MarshalJSON() ([]byte, error)
- func (entry *SwEntry) String() string
- func (entry *SwEntry) UnmarshalJSON([]byte) error
- type SwOption
- func WithEnableCommonServiceSw(enable bool) SwOption
- func WithEventLoggerEntrySw(eventLoggerEntry *rkentry.EventLoggerEntry) SwOption
- func WithHeadersSw(headers map[string]string) SwOption
- func WithJsonPathSw(path string) SwOption
- func WithNameSw(name string) SwOption
- func WithPathSw(path string) SwOption
- func WithPortSw(port uint64) SwOption
- func WithZapLoggerEntrySw(zapLoggerEntry *rkentry.ZapLoggerEntry) SwOption
- type TvEntry
- func (entry *TvEntry) AssetsFileHandler() gin.HandlerFunc
- func (entry *TvEntry) Bootstrap(ctx context.Context)
- func (entry *TvEntry) GetDescription() string
- func (entry *TvEntry) GetName() string
- func (entry *TvEntry) GetType() string
- func (entry *TvEntry) Interrupt(ctx context.Context)
- func (entry *TvEntry) MarshalJSON() ([]byte, error)
- func (entry *TvEntry) String() string
- func (entry *TvEntry) TV(ctx *gin.Context)
- func (entry *TvEntry) UnmarshalJSON([]byte) error
- type TvEntryOption
Constants ¶
const ( CommonServiceEntryType = "GinCommonServiceEntry" CommonServiceEntryNameDefault = "GinCommonServiceDefault" CommonServiceEntryDescription = "Internal RK entry which implements commonly used API with Gin framework." )
const ( GinEntryType = "GinEntry" GinEntryDescription = "Internal RK entry which helps to bootstrap with Gin framework." )
const ( PromEntryType = "GinPromEntry" PromEntryNameDefault = "GinPromDefault" PromEntryDescription = "Internal RK entry which implements prometheus client with Gin framework." )
const ( SwEntryType = "GinSwEntry" SwEntryNameDefault = "GinSwDefault" SwEntryDescription = "Internal RK entry which implements swagger with Gin framework." )
const ( TvEntryType = "GinTvEntry" TvEntryNameDefault = "GinTvDefault" TvEntryDescription = "Internal RK entry which implements tv web with Gin framework." )
Variables ¶
var (
Templates = map[string][]byte{}
)
Functions ¶
func RegisterGinEntriesWithConfig ¶ added in v1.2.0
Register gin 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 BootConfigCommonService ¶ added in v1.2.0
type BootConfigCommonService struct {
Enabled bool `yaml:"enabled" json:"enabled"`
}
Bootstrap config of common service. 1: Enabled: Enable common service.
type BootConfigGin ¶ added in v1.2.0
type BootConfigGin struct { Gin []struct { Name string `yaml:"name" json:"name"` Port uint64 `yaml:"port" json:"port"` Description string `yaml:"description" json:"description"` Cert struct { Ref string `yaml:"ref" json:"ref"` } `yaml:"cert" json:"cert"` SW BootConfigSw `yaml:"sw" json:"sw"` CommonService BootConfigCommonService `yaml:"commonService" json:"commonService"` TV BootConfigTv `yaml:"tv" json:"tv"` Prom BootConfigProm `yaml:"prom" json:"prom"` Interceptors struct { LoggingZap struct { Enabled bool `yaml:"enabled" json:"enabled"` ZapLoggerEncoding string `yaml:"zapLoggerEncoding" json:"zapLoggerEncoding"` ZapLoggerOutputPaths []string `yaml:"zapLoggerOutputPaths" json:"zapLoggerOutputPaths"` EventLoggerEncoding string `yaml:"eventLoggerEncoding" json:"eventLoggerEncoding"` EventLoggerOutputPaths []string `yaml:"eventLoggerOutputPaths" json:"eventLoggerOutputPaths"` } `yaml:"loggingZap" json:"loggingZap"` MetricsProm struct { Enabled bool `yaml:"enabled" json:"enabled"` } `yaml:"metricsProm" json:"metricsProm"` Auth struct { Enabled bool `yaml:"enabled" json:"enabled"` IgnorePrefix []string `yaml:"ignorePrefix" json:"ignorePrefix"` Basic []string `yaml:"basic" json:"basic"` ApiKey []string `yaml:"apiKey" json:"apiKey"` } `yaml:"auth" json:"auth"` Meta struct { Enabled bool `yaml:"enabled" json:"enabled"` Prefix string `yaml:"prefix" json:"prefix"` } `yaml:"meta" json:"meta"` TracingTelemetry struct { Enabled bool `yaml:"enabled" json:"enabled"` Exporter struct { File struct { Enabled bool `yaml:"enabled" json:"enabled"` OutputPath string `yaml:"outputPath" json:"outputPath"` } `yaml:"file" json:"file"` Jaeger struct { Enabled bool `yaml:"enabled" json:"enabled"` CollectorEndpoint string `yaml:"collectorEndpoint" json:"collectorEndpoint"` CollectorUsername string `yaml:"collectorUsername" json:"collectorUsername"` CollectorPassword string `yaml:"collectorPassword" json:"collectorPassword"` } `yaml:"jaeger" json:"jaeger"` } `yaml:"exporter" json:"exporter"` } `yaml:"tracingTelemetry" json:"tracingTelemetry"` } `yaml:"interceptors" json:"interceptors"` Logger struct { ZapLogger struct { Ref string `yaml:"ref" json:"ref"` } `yaml:"zapLogger" json:"zapLogger"` EventLogger struct { Ref string `yaml:"ref" json:"ref"` } `yaml:"eventLogger" json:"eventLogger"` } `yaml:"logger" json:"logger"` } `yaml:"gin" json:"gin"` }
Boot config which is for gin entry.
1: Gin.Name: Name of gin entry, should be unique globally. 2: Gin.Port: Port of gin entry. 3: Gin.Cert.Ref: Reference of rkentry.CertEntry. 4: Gin.SW: See BootConfigSW for details. 5: Gin.CommonService: See BootConfigCommonService for details. 6: Gin.TV: See BootConfigTv for details. 7: Gin.Prom: See BootConfigProm for details. 8: Gin.Interceptors.LoggingZap.Enabled: Enable zap logging interceptor. 9: Gin.Interceptors.MetricsProm.Enable: Enable prometheus interceptor. 10: Gin.Interceptors.auth.Enabled: Enable basic auth. 11: Gin.Interceptors.auth.Basic: Credential for basic auth, scheme: <user:pass> 12: Gin.Interceptors.auth.ApiKey: Credential for X-API-Key. 13: Gin.Interceptors.auth.igorePrefix: List of paths that will be ignored. 14: Gin.Interceptors.Extension.Enabled: Enable extension interceptor. 15: Gin.Interceptors.Extension.Prefix: Prefix of extension header key. 16: Gin.Interceptors.TracingTelemetry.Enabled: Enable tracing interceptor with opentelemetry. 17: Gin.Interceptors.TracingTelemetry.Exporter.File.Enabled: Enable file exporter which support type of stdout and local file. 18: Gin.Interceptors.TracingTelemetry.Exporter.File.OutputPath: Output path of file exporter, stdout and file path is supported. 19: Gin.Interceptors.TracingTelemetry.Exporter.Jaeger.Enabled: Enable jaeger exporter. 20: Gin.Interceptors.TracingTelemetry.Exporter.Jaeger.AgentEndpoint: Specify jeager agent endpoint, localhost:6832 would be used by default. 21: Gin.Logger.ZapLogger.Ref: Zap logger reference, see rkentry.ZapLoggerEntry for details. 22: Gin.Logger.EventLogger.Ref: Event logger reference, see rkentry.EventLoggerEntry for details.
type BootConfigProm ¶ added in v1.2.0
type BootConfigProm struct { Path string `yaml:"path" json:"path"` Enabled bool `yaml:"enabled" json:"enabled"` Pusher struct { Enabled bool `yaml:"enabled" json:"enabled"` IntervalMs int64 `yaml:"IntervalMs" json:"IntervalMs"` JobName string `yaml:"jobName" json:"jobName"` RemoteAddress string `yaml:"remoteAddress" json:"remoteAddress"` BasicAuth string `yaml:"basicAuth" json:"basicAuth"` Cert struct { Ref string `yaml:"ref" json:"ref"` } `yaml:"cert" json:"cert"` } `yaml:"pusher" json:"pusher"` }
Boot config which is for prom entry.
1: Path: PromEntry path, /metrics is default value. 2: Enabled: Enable prom entry. 3: Pusher.Enabled: Enable pushgateway pusher. 4: Pusher.IntervalMs: Interval of pushing metrics to remote pushgateway in milliseconds. 5: Pusher.JobName: Job name would be attached as label while pushing to remote pushgateway. 6: Pusher.RemoteAddress: Pushgateway address, could be form of http://x.x.x.x or x.x.x.x 7: Pusher.BasicAuth: Basic auth used to interact with remote pushgateway. 8: Pusher.Cert.Ref: Reference of rkentry.CertEntry. 9: Cert.Ref: Reference of rkentry.CertEntry.
type BootConfigSw ¶ added in v1.2.0
type BootConfigSw struct { Enabled bool `yaml:"enabled" yaml:"enabled"` Path string `yaml:"path" yaml:"path"` JsonPath string `yaml:"jsonPath" yaml:"jsonPath"` Headers []string `yaml:"headers" yaml:"headers"` }
Bootstrap config of swagger. 1: Enabled: Enable swagger. 2: Path: Swagger path accessible from restful API. 3: JsonPath: The path of where swagger JSON file was located. 4: Headers: The headers that would added into each API response.
type BootConfigTv ¶ added in v1.2.0
type BootConfigTv struct {
Enabled bool `yaml:"enabled" json:"enabled"`
}
Bootstrap config of tv. 1: Enabled: Enable tv service.
type CommonServiceEntry ¶ added in v1.2.0
type CommonServiceEntry struct { EntryName string `json:"entryName" yaml:"entryName"` EntryType string `json:"entryType" yaml:"entryType"` EntryDescription string `json:"entryDescription" yaml:"entryDescription"` EventLoggerEntry *rkentry.EventLoggerEntry `json:"-" yaml:"-"` ZapLoggerEntry *rkentry.ZapLoggerEntry `json:"-" yaml:"-"` }
RK common service which contains commonly used APIs 1: Healthy Returns true if process is alive 2: Gc Trigger gc() 3: Info Returns entry basic information 4: Configs Returns viper configs in GlobalAppCtx 5: Apis Returns list of apis registered in gin router 6: Sys Returns CPU and Memory information 7: Req Returns request metrics 8: Certs Returns certificates 9: Entries Returns entries 10: Logs Returns log entries 12: Deps Returns dependency which is full go.mod file content 13: License Returns license file content 14: Readme Returns README file content
func NewCommonServiceEntry ¶ added in v1.2.0
func NewCommonServiceEntry(opts ...CommonServiceEntryOption) *CommonServiceEntry
Create new common service entry with options.
func (*CommonServiceEntry) Apis ¶ added in v1.2.0
func (entry *CommonServiceEntry) Apis(ctx *gin.Context)
@Summary List API @Id 5 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @produce application/json @Success 200 {object} rkentry.ApisResponse @Router /rk/v1/apis [get]
func (*CommonServiceEntry) Bootstrap ¶ added in v1.2.0
func (entry *CommonServiceEntry) Bootstrap(ctx context.Context)
Bootstrap common service entry.
func (*CommonServiceEntry) Certs ¶ added in v1.2.0
func (entry *CommonServiceEntry) Certs(ctx *gin.Context)
@Summary List CertEntry @Id 9 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @produce application/json @Success 200 {object} rkentry.CertsResponse @Router /rk/v1/certs [get]
func (*CommonServiceEntry) Configs ¶ added in v1.2.0
func (entry *CommonServiceEntry) Configs(ctx *gin.Context)
@Summary List ConfigEntry @Id 4 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @produce application/json @Success 200 {object} rkentry.ConfigsResponse @Router /rk/v1/configs [get]
func (*CommonServiceEntry) Deps ¶ added in v1.2.0
func (entry *CommonServiceEntry) Deps(ctx *gin.Context)
@Summary List dependencies related application @Id 11 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @produce application/json @Success 200 {object} rkentry.DepResponse @Router /rk/v1/deps [get]
func (*CommonServiceEntry) Entries ¶ added in v1.2.0
func (entry *CommonServiceEntry) Entries(ctx *gin.Context)
@Summary List all Entry @Id 8 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @produce application/json @Success 200 {object} rkentry.EntriesResponse @Router /rk/v1/entries [get]
func (*CommonServiceEntry) Gc ¶ added in v1.2.0
func (entry *CommonServiceEntry) Gc(ctx *gin.Context)
@Summary Trigger Gc @Id 2 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @produce application/json @Success 200 {object} rkentry.GcResponse @Router /rk/v1/gc [get]
func (*CommonServiceEntry) GetDescription ¶ added in v1.2.0
func (entry *CommonServiceEntry) GetDescription() string
Get description of entry.
func (*CommonServiceEntry) GetName ¶ added in v1.2.0
func (entry *CommonServiceEntry) GetName() string
Get name of entry.
func (*CommonServiceEntry) GetType ¶ added in v1.2.0
func (entry *CommonServiceEntry) GetType() string
Get entry type.
func (*CommonServiceEntry) Git ¶ added in v1.2.0
func (entry *CommonServiceEntry) Git(ctx *gin.Context)
@Summary Get Git information. @Id 14 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @produce application/json @Success 200 {object} rkentry.GitResponse @Router /rk/v1/git [get]
func (*CommonServiceEntry) Healthy ¶ added in v1.2.0
func (entry *CommonServiceEntry) Healthy(ctx *gin.Context)
@Summary Get application healthy status @Id 1 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @produce application/json @Success 200 {object} rkentry.HealthyResponse @Router /rk/v1/healthy [get]
func (*CommonServiceEntry) Info ¶ added in v1.2.0
func (entry *CommonServiceEntry) Info(ctx *gin.Context)
@Summary Get application and process info @Id 3 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @produce application/json @Success 200 {object} rkentry.ProcessInfo @Router /rk/v1/info [get]
func (*CommonServiceEntry) Interrupt ¶ added in v1.2.0
func (entry *CommonServiceEntry) Interrupt(ctx context.Context)
Interrupt common service entry.
func (*CommonServiceEntry) License ¶ added in v1.2.0
func (entry *CommonServiceEntry) License(ctx *gin.Context)
@Summary Get license related application @Id 12 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @produce application/json @Success 200 {object} rkentry.LicenseResponse @Router /rk/v1/license [get]
func (*CommonServiceEntry) Logs ¶ added in v1.2.0
func (entry *CommonServiceEntry) Logs(ctx *gin.Context)
@Summary List logger related entries @Id 10 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @produce application/json @Success 200 {object} rkentry.LogsResponse @Router /rk/v1/logs [get]
func (*CommonServiceEntry) MarshalJSON ¶ added in v1.2.0
func (entry *CommonServiceEntry) MarshalJSON() ([]byte, error)
Marshal entry.
func (*CommonServiceEntry) Readme ¶ added in v1.2.0
func (entry *CommonServiceEntry) Readme(ctx *gin.Context)
@Summary Get README file. @Id 13 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @produce application/json @Success 200 {object} rkentry.ReadmeResponse @Router /rk/v1/readme [get]
func (*CommonServiceEntry) Req ¶ added in v1.2.0
func (entry *CommonServiceEntry) Req(ctx *gin.Context)
@Summary List prometheus metrics of requests @Id 7 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @produce application/json @success 200 {object} rkentry.ReqResponse @Router /rk/v1/req [get]
func (*CommonServiceEntry) String ¶ added in v1.2.0
func (entry *CommonServiceEntry) String() string
Stringfy entry.
func (*CommonServiceEntry) Sys ¶ added in v1.2.0
func (entry *CommonServiceEntry) Sys(ctx *gin.Context)
@Summary Get OS Stat @Id 6 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @produce application/json @Success 200 {object} rkentry.SysResponse @Router /rk/v1/sys [get]
func (*CommonServiceEntry) UnmarshalJSON ¶ added in v1.2.0
func (entry *CommonServiceEntry) UnmarshalJSON([]byte) error
Not supported.
type CommonServiceEntryOption ¶ added in v1.2.0
type CommonServiceEntryOption func(*CommonServiceEntry)
Common service entry option.
func WithEventLoggerEntryCommonService ¶ added in v1.2.0
func WithEventLoggerEntryCommonService(eventLoggerEntry *rkentry.EventLoggerEntry) CommonServiceEntryOption
Provide rkentry.EventLoggerEntry.
func WithNameCommonService ¶ added in v1.2.0
func WithNameCommonService(name string) CommonServiceEntryOption
Provide name.
func WithZapLoggerEntryCommonService ¶ added in v1.2.0
func WithZapLoggerEntryCommonService(zapLoggerEntry *rkentry.ZapLoggerEntry) CommonServiceEntryOption
Provide rkentry.ZapLoggerEntry.
type GinEntry ¶
type GinEntry struct { EntryName string `json:"entryName" yaml:"entryName"` EntryType string `json:"entryType" yaml:"entryType"` EntryDescription string `json:"entryDescription" yaml:"entryDescription"` ZapLoggerEntry *rkentry.ZapLoggerEntry `json:"zapLoggerEntry" yaml:"zapLoggerEntry"` EventLoggerEntry *rkentry.EventLoggerEntry `json:"eventLoggerEntry" yaml:"eventLoggerEntry"` Router *gin.Engine `json:"-" yaml:"-"` Server *http.Server `json:"-" yaml:"-"` Port uint64 `json:"port" yaml:"port"` Interceptors []gin.HandlerFunc `json:"-" yaml:"-"` SwEntry *SwEntry `json:"swEntry" yaml:"swEntry"` CertEntry *rkentry.CertEntry `json:"certEntry" yaml:"certEntry"` CommonServiceEntry *CommonServiceEntry `json:"commonServiceEntry" yaml:"commonServiceEntry"` PromEntry *PromEntry `json:"promEntry" yaml:"promEntry"` TvEntry *TvEntry `json:"tvEntry" yaml:"tvEntry"` }
GinEntry implements rkentry.Entry interface.
1: ZapLoggerEntry: See rkentry.ZapLoggerEntry for details. 2: EventLoggerEntry: See rkentry.EventLoggerEntry for details. 3: Router: gin.Engine created while bootstrapping. 4: Server: http.Server created while bootstrapping. 5: Port: http/https port server listen to. 6: Interceptors: Interceptors user enabled from YAML config, by default, rkginpanic.PanicInterceptor would be injected. 7: SwEntry: See SWEntry for details. 8: CertEntry: See CertEntry for details.. 9: CommonServiceEntry: See CommonServiceEntry for details. 10: PromEntry: See PromEntry for details. 11: TvEntry: See TvEntry for details.
func GetGinEntry ¶ added in v1.2.0
Get GinEntry from rkentry.GlobalAppCtx.
func RegisterGinEntry ¶ added in v1.2.0
func RegisterGinEntry(opts ...GinEntryOption) *GinEntry
Register GinEntry with options.
func (*GinEntry) AddInterceptor ¶ added in v1.2.0
func (entry *GinEntry) AddInterceptor(inters ...gin.HandlerFunc)
Add interceptors. This function should be called before Bootstrap() called.
func (*GinEntry) GetDescription ¶ added in v1.2.0
Get description of entry.
func (*GinEntry) IsCommonServiceEnabled ¶ added in v1.2.0
Is common service entry enabled?
func (*GinEntry) IsPromEnabled ¶ added in v1.2.0
Is prometheus entry enabled?
func (*GinEntry) IsSwEnabled ¶ added in v1.2.0
Is swagger entry enabled?
func (*GinEntry) IsTlsEnabled ¶ added in v1.1.3
Is TLS enabled?
func (*GinEntry) IsTvEnabled ¶ added in v1.2.0
Is TV entry enabled?
func (*GinEntry) MarshalJSON ¶ added in v1.2.0
Marshal entry.
func (*GinEntry) RegisterInterceptor ¶ added in v1.2.0
func (entry *GinEntry) RegisterInterceptor(interceptor gin.HandlerFunc)
Register interceptor, please make sure call this function before Bootstrap().
func (*GinEntry) UnmarshalJSON ¶ added in v1.2.0
Not supported.
type GinEntryOption ¶
type GinEntryOption func(*GinEntry)
Gin entry option.
func WithCertEntryGin ¶ added in v1.2.0
func WithCertEntryGin(certEntry *rkentry.CertEntry) GinEntryOption
Provide rkentry.CertEntry.
func WithCommonServiceEntryGin ¶ added in v1.2.0
func WithCommonServiceEntryGin(commonServiceEntry *CommonServiceEntry) GinEntryOption
Provide CommonServiceEntry.
func WithDescriptionGin ¶ added in v1.2.0
func WithDescriptionGin(description string) GinEntryOption
Provide name.
func WithEventLoggerEntryGin ¶ added in v1.2.0
func WithEventLoggerEntryGin(eventLogger *rkentry.EventLoggerEntry) GinEntryOption
Provide rkentry.EventLoggerEntry.
func WithInterceptorsGin ¶ added in v1.2.0
func WithInterceptorsGin(inters ...gin.HandlerFunc) GinEntryOption
Provide user interceptors.
func WithPromEntryGin ¶ added in v1.2.0
func WithPromEntryGin(prom *PromEntry) GinEntryOption
Provide PromEntry.
func WithSwEntryGin ¶ added in v1.2.0
func WithSwEntryGin(sw *SwEntry) GinEntryOption
Provide SwEntry.
func WithTVEntryGin ¶ added in v1.2.0
func WithTVEntryGin(tvEntry *TvEntry) GinEntryOption
Provide TvEntry.
func WithZapLoggerEntryGin ¶ added in v1.2.0
func WithZapLoggerEntryGin(zapLogger *rkentry.ZapLoggerEntry) GinEntryOption
Provide rkentry.ZapLoggerEntry.
type PromEntry ¶ added in v1.2.0
type PromEntry struct { Pusher *rkprom.PushGatewayPusher `json:"pushGateWayPusher" yaml:"pushGateWayPusher"` EntryName string `json:"entryName" yaml:"entryName"` EntryType string `json:"entryType" yaml:"entryType"` EntryDescription string `json:"entryDescription" yaml:"entryDescription"` ZapLoggerEntry *rkentry.ZapLoggerEntry `json:"zapLoggerEntry" yaml:"zapLoggerEntry"` EventLoggerEntry *rkentry.EventLoggerEntry `json:"eventLoggerEntry" yaml:"eventLoggerEntry"` Port uint64 `json:"port" yaml:"port"` Path string `json:"path" yaml:"path"` Registry *prometheus.Registry `json:"-" yaml:"-"` Registerer prometheus.Registerer `json:"-" yaml:"-"` Gatherer prometheus.Gatherer `json:"-" yaml:"-"` }
Prometheus entry which implements rkentry.Entry.
1: Pusher Periodic pushGateway pusher 2: ZapLoggerEntry rkentry.ZapLoggerEntry 3: EventLoggerEntry rkentry.EventLoggerEntry 4: Port Exposed port by prom entry 5: Path Exposed path by prom entry 6: Registry Prometheus registry 7: Registerer Prometheus registerer 8: Gatherer Prometheus gatherer
func NewPromEntry ¶ added in v1.2.0
func NewPromEntry(opts ...PromEntryOption) *PromEntry
Create a prom entry with options and add prom entry to rk_ctx.GlobalAppCtx
func (*PromEntry) GetDescription ¶ added in v1.2.0
Get description of entry
func (*PromEntry) MarshalJSON ¶ added in v1.2.0
Marshal entry
func (*PromEntry) RegisterCollectors ¶ added in v1.2.0
func (entry *PromEntry) RegisterCollectors(collectors ...prometheus.Collector) error
Register collectors in default registry
func (*PromEntry) UnmarshalJSON ¶ added in v1.2.0
Unmarshal entry
type PromEntryOption ¶ added in v1.2.0
type PromEntryOption func(*PromEntry)
Prom entry option used while initializing prom entry via code
func WithEventLoggerEntryProm ¶ added in v1.2.0
func WithEventLoggerEntryProm(eventLoggerEntry *rkentry.EventLoggerEntry) PromEntryOption
rkentry.EventLoggerEntry of prom entry
func WithNameProm ¶ added in v1.2.0
func WithNameProm(name string) PromEntryOption
Name of prom entry
func WithPathProm ¶ added in v1.2.0
func WithPathProm(path string) PromEntryOption
Path of prom entry
func WithPortProm ¶ added in v1.2.0
func WithPortProm(port uint64) PromEntryOption
Port of prom entry
func WithPromRegistryProm ¶ added in v1.2.0
func WithPromRegistryProm(registry *prometheus.Registry) PromEntryOption
Provide a new prometheus registry
func WithPusherProm ¶ added in v1.2.0
func WithPusherProm(pusher *rkprom.PushGatewayPusher) PromEntryOption
PushGateway of prom entry
func WithZapLoggerEntryProm ¶ added in v1.2.0
func WithZapLoggerEntryProm(zapLoggerEntry *rkentry.ZapLoggerEntry) PromEntryOption
rkentry.ZapLoggerEntry of prom entry
type SwEntry ¶ added in v1.2.0
type SwEntry struct { EntryName string `json:"entryName" yaml:"entryName"` EntryType string `json:"entryType" yaml:"entryType"` EntryDescription string `json:"entryDescription" yaml:"entryDescription"` EventLoggerEntry *rkentry.EventLoggerEntry `json:"eventLoggerEntry" yaml:"eventLoggerEntry"` ZapLoggerEntry *rkentry.ZapLoggerEntry `json:"zapLoggerEntry" yaml:"zapLoggerEntry"` JsonPath string `json:"jsonPath" yaml:"jsonPath"` Path string `json:"path" yaml:"path"` Headers map[string]string `json:"headers" yaml:"headers"` Port uint64 `json:"port" yaml:"port"` EnableCommonService bool `json:"enableCommonService" yaml:"enableCommonService"` }
SwEntry implements rkentry.Entry interface. 1: Path: Swagger path accessible from restful API. 2: JsonPath: The path of where swagger JSON file was located. 3: Headers: The headers that would added into each API response. 4: Port: The port where swagger would listen to. 5: EnableCommonService: Enable common service in swagger.
func NewSwEntry ¶ added in v1.2.0
Create new swagger entry with options.
func (*SwEntry) AssetsFileHandler ¶ added in v1.2.0
func (entry *SwEntry) AssetsFileHandler() gin.HandlerFunc
Handler for swagger assets files.
func (*SwEntry) ConfigFileHandler ¶ added in v1.2.0
func (entry *SwEntry) ConfigFileHandler() gin.HandlerFunc
handler for swagger config files.
func (*SwEntry) GetDescription ¶ added in v1.2.0
Get description of entry
func (*SwEntry) MarshalJSON ¶ added in v1.2.0
Marshal entry
func (*SwEntry) UnmarshalJSON ¶ added in v1.2.0
Unmarshal entry
type SwOption ¶ added in v1.2.0
type SwOption func(*SwEntry)
Swagger entry option.
func WithEnableCommonServiceSw ¶ added in v1.2.0
Provide enable common service option.
func WithEventLoggerEntrySw ¶ added in v1.2.0
func WithEventLoggerEntrySw(eventLoggerEntry *rkentry.EventLoggerEntry) SwOption
Provide rkentry.EventLoggerEntry.
func WithHeadersSw ¶ added in v1.2.0
Provide headers.
func WithZapLoggerEntrySw ¶ added in v1.2.0
func WithZapLoggerEntrySw(zapLoggerEntry *rkentry.ZapLoggerEntry) SwOption
Provide rkentry.ZapLoggerEntry.
type TvEntry ¶ added in v1.2.0
type TvEntry struct { EntryName string `json:"entryName" yaml:"entryName"` EntryType string `json:"entryType" yaml:"entryType"` EntryDescription string `json:"entryDescription" yaml:"entryDescription"` ZapLoggerEntry *rkentry.ZapLoggerEntry `json:"zapLoggerEntry" yaml:"zapLoggerEntry"` EventLoggerEntry *rkentry.EventLoggerEntry `json:"eventLoggerEntry" yaml:"eventLoggerEntry"` Template *template.Template `json:"-" yaml:"-"` }
RK TV entry supports web UI for application & process information. 1: EntryName: Name of entry. 2: EntryType: Type of entry. 2: EntryDescription: Description of entry. 3: ZapLoggerEntry: ZapLoggerEntry used for logging. 4: EventLoggerEntry: EventLoggerEntry used for logging. 5: Template: GO template for rendering web UI.
func NewTvEntry ¶ added in v1.2.0
func NewTvEntry(opts ...TvEntryOption) *TvEntry
Create new TV entry with options.
func (*TvEntry) AssetsFileHandler ¶ added in v1.2.0
func (entry *TvEntry) AssetsFileHandler() gin.HandlerFunc
Handler which returns js, css, images and html files for TV web UI.
func (*TvEntry) Bootstrap ¶ added in v1.2.0
Bootstrap TV entry. Rendering bellow templates. 1: head.tmpl 2: header.tmpl 3: footer.tmpl 4: aside.tmpl 5: svg-sprite.tmpl 6: overview.tmpl 7: apis.tmpl 8: entries.tmpl 9: configs.tmpl 10: certs.tmpl 11: os.tmpl 12: env.tmpl 13: prometheus.tmpl 14: logs.tmpl 15: deps.tmpl 16: license.tmpl 17: info.tmpl
func (*TvEntry) GetDescription ¶ added in v1.2.0
Get description of entry.
func (*TvEntry) MarshalJSON ¶ added in v1.2.0
Marshal entry
func (*TvEntry) TV ¶ added in v1.2.0
@Summary Get HTML page of /tv @Id 15 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @produce text/html @Success 200 string HTML @Router /rk/v1/tv [get]
func (*TvEntry) UnmarshalJSON ¶ added in v1.2.0
Not supported.
type TvEntryOption ¶ added in v1.2.0
type TvEntryOption func(entry *TvEntry)
TV entry option.
func WithEventLoggerEntryTv ¶ added in v1.2.0
func WithEventLoggerEntryTv(eventLoggerEntry *rkentry.EventLoggerEntry) TvEntryOption
Provide rkentry.EventLoggerEntry.
func WithZapLoggerEntryTv ¶ added in v1.2.0
func WithZapLoggerEntryTv(zapLoggerEntry *rkentry.ZapLoggerEntry) TvEntryOption
Provide rkentry.ZapLoggerEntry.