rkgin

package
v1.2.11 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2021 License: Apache-2.0 Imports: 48 Imported by: 4

Documentation

Overview

Package rkgin an implementation of rkentry.Entry which could be used start restful server with gin framework

Index

Constants

View Source
const (
	// CommonServiceEntryType type of entry
	CommonServiceEntryType = "GinCommonServiceEntry"
	// CommonServiceEntryNameDefault name of entry
	CommonServiceEntryNameDefault = "GinCommonServiceDefault"
	// CommonServiceEntryDescription description of entry
	CommonServiceEntryDescription = "Internal RK entry which implements commonly used API with Gin framework."
)
View Source
const (
	// GinEntryType type of entry
	GinEntryType = "GinEntry"
	// GinEntryDescription description of entry
	GinEntryDescription = "Internal RK entry which helps to bootstrap with Gin framework."
)
View Source
const (
	// PromEntryType default entry type
	PromEntryType = "GinPromEntry"
	// PromEntryNameDefault default entry name
	PromEntryNameDefault = "GinPromDefault"
	// PromEntryDescription default entry description
	PromEntryDescription = "Internal RK entry which implements prometheus client with Gin framework."
)
View Source
const (
	// StaticFileHandlerEntryType type of entry
	StaticFileHandlerEntryType = "GinStaticFileHandlerEntry"
	// StaticFileHandlerEntryNameDefault name of entry
	StaticFileHandlerEntryNameDefault = "GinStaticFileHandlerDefault"
	// StaticFileHandlerEntryDescription description of entry
	StaticFileHandlerEntryDescription = "Internal RK entry which implements static file handler Gin framework."
)
View Source
const (
	// SwEntryType default entry type
	SwEntryType = "GinSwEntry"
	// SwEntryNameDefault default entry name
	SwEntryNameDefault = "GinSwDefault"
	// SwEntryDescription default entry description
	SwEntryDescription = "Internal RK entry which implements swagger with Gin framework."
)
View Source
const (
	// TvEntryType default entry type
	TvEntryType = "GinTvEntry"
	// TvEntryNameDefault default entry name
	TvEntryNameDefault = "GinTvDefault"
	// TvEntryDescription default entry description
	TvEntryDescription = "Internal RK entry which implements tv web with Gin framework."
)

Variables

View Source
var (
	// Templates is a map to store go template
	Templates = map[string][]byte{}
)

Functions

func RegisterGinEntriesWithConfig added in v1.2.0

func RegisterGinEntriesWithConfig(configFilePath string) map[string]rkentry.Entry

RegisterGinEntriesWithConfig 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"`
}

BootConfigCommonService Bootstrap config of common service. 1: Enabled: Enable common service.

type BootConfigGin added in v1.2.0

type BootConfigGin struct {
	Gin []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"`
		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"`
		Static        BootConfigStaticHandler `yaml:"static" json:"static"`
		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"`
			Cors struct {
				Enabled          bool     `yaml:"enabled" json:"enabled"`
				AllowOrigins     []string `yaml:"allowOrigins" json:"allowOrigins"`
				AllowCredentials bool     `yaml:"allowCredentials" json:"allowCredentials"`
				AllowHeaders     []string `yaml:"allowHeaders" json:"allowHeaders"`
				AllowMethods     []string `yaml:"allowMethods" json:"allowMethods"`
				ExposeHeaders    []string `yaml:"exposeHeaders" json:"exposeHeaders"`
				MaxAge           int      `yaml:"maxAge" json:"maxAge"`
			} `yaml:"cors" json:"cors"`
			Meta struct {
				Enabled bool   `yaml:"enabled" json:"enabled"`
				Prefix  string `yaml:"prefix" json:"prefix"`
			} `yaml:"meta" json:"meta"`
			Jwt struct {
				Enabled      bool     `yaml:"enabled" json:"enabled"`
				IgnorePrefix []string `yaml:"ignorePrefix" json:"ignorePrefix"`
				SigningKey   string   `yaml:"signingKey" json:"signingKey"`
				SigningKeys  []string `yaml:"signingKeys" json:"signingKeys"`
				SigningAlgo  string   `yaml:"signingAlgo" json:"signingAlgo"`
				TokenLookup  string   `yaml:"tokenLookup" json:"tokenLookup"`
				AuthScheme   string   `yaml:"authScheme" json:"authScheme"`
			} `yaml:"jwt" json:"jwt"`
			Secure struct {
				Enabled               bool     `yaml:"enabled" json:"enabled"`
				IgnorePrefix          []string `yaml:"ignorePrefix" json:"ignorePrefix"`
				XssProtection         string   `yaml:"xssProtection" json:"xssProtection"`
				ContentTypeNosniff    string   `yaml:"contentTypeNosniff" json:"contentTypeNosniff"`
				XFrameOptions         string   `yaml:"xFrameOptions" json:"xFrameOptions"`
				HstsMaxAge            int      `yaml:"hstsMaxAge" json:"hstsMaxAge"`
				HstsExcludeSubdomains bool     `yaml:"hstsExcludeSubdomains" json:"hstsExcludeSubdomains"`
				HstsPreloadEnabled    bool     `yaml:"hstsPreloadEnabled" json:"hstsPreloadEnabled"`
				ContentSecurityPolicy string   `yaml:"contentSecurityPolicy" json:"contentSecurityPolicy"`
				CspReportOnly         bool     `yaml:"cspReportOnly" json:"cspReportOnly"`
				ReferrerPolicy        string   `yaml:"referrerPolicy" json:"referrerPolicy"`
			} `yaml:"secure" json:"secure"`
			RateLimit struct {
				Enabled   bool   `yaml:"enabled" json:"enabled"`
				Algorithm string `yaml:"algorithm" json:"algorithm"`
				ReqPerSec int    `yaml:"reqPerSec" json:"reqPerSec"`
				Paths     []struct {
					Path      string `yaml:"path" json:"path"`
					ReqPerSec int    `yaml:"reqPerSec" json:"reqPerSec"`
				} `yaml:"paths" json:"paths"`
			} `yaml:"rateLimit" json:"rateLimit"`
			Csrf struct {
				Enabled        bool     `yaml:"enabled" json:"enabled"`
				IgnorePrefix   []string `yaml:"ignorePrefix" json:"ignorePrefix"`
				TokenLength    int      `yaml:"tokenLength" json:"tokenLength"`
				TokenLookup    string   `yaml:"tokenLookup" json:"tokenLookup"`
				CookieName     string   `yaml:"cookieName" json:"cookieName"`
				CookieDomain   string   `yaml:"cookieDomain" json:"cookieDomain"`
				CookiePath     string   `yaml:"cookiePath" json:"cookiePath"`
				CookieMaxAge   int      `yaml:"cookieMaxAge" json:"cookieMaxAge"`
				CookieHttpOnly bool     `yaml:"cookieHttpOnly" json:"cookieHttpOnly"`
				CookieSameSite string   `yaml:"cookieSameSite" json:"cookieSameSite"`
			} `yaml:"csrf" yaml:"csrf"`
			Gzip struct {
				Enabled bool   `yaml:"enabled" json:"enabled"`
				Level   string `yaml:"level" json:"level"`
			} `yaml:"gzip" json:"gzip"`
			Timeout struct {
				Enabled   bool `yaml:"enabled" json:"enabled"`
				TimeoutMs int  `yaml:"timeoutMs" json:"timeoutMs"`
				Paths     []struct {
					Path      string `yaml:"path" json:"path"`
					TimeoutMs int    `yaml:"timeoutMs" json:"timeoutMs"`
				} `yaml:"paths" json:"paths"`
			} `yaml:"timeout" json:"timeout"`
			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 {
						Agent struct {
							Enabled bool   `yaml:"enabled" json:"enabled"`
							Host    string `yaml:"host" json:"host"`
							Port    int    `yaml:"port" json:"port"`
						} `yaml:"agent" json:"agent"`
						Collector struct {
							Enabled  bool   `yaml:"enabled" json:"enabled"`
							Endpoint string `yaml:"endpoint" json:"endpoint"`
							Username string `yaml:"username" json:"username"`
							Password string `yaml:"password" json:"password"`
						} `yaml:"collector" json:"collector"`
					} `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"`
}

BootConfigGin boot config which is for gin entry.

1: Gin.Enabled: Enable gin entry, default is true. 2: Gin.Name: Name of gin entry, should be unique globally. 3: Gin.Port: Port of gin entry. 4: Gin.Cert.Ref: Reference of rkentry.CertEntry. 5: Gin.SW: See BootConfigSW for details. 6: Gin.CommonService: See BootConfigCommonService for details. 7: Gin.TV: See BootConfigTv for details. 8: Gin.Prom: See BootConfigProm for details. 9: Gin.Interceptors.LoggingZap.Enabled: Enable zap logging interceptor. 10: Gin.Interceptors.MetricsProm.Enable: Enable prometheus interceptor. 11: Gin.Interceptors.auth.Enabled: Enable basic auth. 12: Gin.Interceptors.auth.Basic: Credential for basic auth, scheme: <user:pass> 13: Gin.Interceptors.auth.ApiKey: Credential for X-API-Key. 14: Gin.Interceptors.auth.igorePrefix: List of paths that will be ignored. 15: Gin.Interceptors.Extension.Enabled: Enable extension interceptor. 16: Gin.Interceptors.Extension.Prefix: Prefix of extension header key. 17: Gin.Interceptors.TracingTelemetry.Enabled: Enable tracing interceptor with opentelemetry. 18: Gin.Interceptors.TracingTelemetry.Exporter.File.Enabled: Enable file exporter which support type of stdout and local file. 19: Gin.Interceptors.TracingTelemetry.Exporter.File.OutputPath: Output path of file exporter, stdout and file path is supported. 20: Gin.Interceptors.TracingTelemetry.Exporter.Jaeger.Enabled: Enable jaeger exporter. 21: Gin.Interceptors.TracingTelemetry.Exporter.Jaeger.AgentEndpoint: Specify jeager agent endpoint, localhost:6832 would be used by default. 22: Gin.Interceptors.RateLimit.Enabled: Enable rate limit interceptor. 23: Gin.Interceptors.RateLimit.Algorithm: Algorithm of rate limiter. 24: Gin.Interceptors.RateLimit.ReqPerSec: Request per second. 25: Gin.Interceptors.RateLimit.Paths.path: Name of full path. 26: Gin.Interceptors.RateLimit.Paths.ReqPerSec: Request per second by path. 27: Gin.Interceptors.Timeout.Enabled: Enable timeout interceptor. 28: Gin.Interceptors.Timeout.TimeoutMs: Timeout in milliseconds. 29: Gin.Interceptors.Timeout.Paths.path: Name of full path. 30: Gin.Interceptors.Timeout.Paths.TimeoutMs: Timeout in milliseconds by path. 31: Gin.Logger.ZapLogger.Ref: Zap logger reference, see rkentry.ZapLoggerEntry for details. 32: 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"`
}

BootConfigProm 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 BootConfigStaticHandler added in v1.2.11

type BootConfigStaticHandler struct {
	Enabled    bool   `yaml:"enabled" json:"enabled"`
	Path       string `yaml:"path" json:"path"`
	SourceType string `yaml:"sourceType" json:"sourceType"`
	SourcePath string `yaml:"sourcePath" json:"sourcePath"`
}

BootConfigStaticHandler bootstrap config of StaticHandler.

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"`
}

BootConfigSw 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"`
}

BootConfigTv 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:"-"`
}

CommonServiceEntry 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

NewCommonServiceEntry Create new common service entry with options.

func (*CommonServiceEntry) Apis added in v1.2.0

func (entry *CommonServiceEntry) Apis(ctx *gin.Context)

Apis handler @Summary List API @Id 5 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @Security JWT @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)

Certs handler @Summary List CertEntry @Id 9 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @Security JWT @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)

Configs handler @Summary List ConfigEntry @Id 4 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @Security JWT @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)

Deps handler @Summary List dependencies related application @Id 11 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @Security JWT @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)

Entries handler @Summary List all Entry @Id 8 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @Security JWT @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)

Gc handler @Summary Trigger Gc @Id 2 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @Security JWT @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

GetDescription Get description of entry.

func (*CommonServiceEntry) GetName added in v1.2.0

func (entry *CommonServiceEntry) GetName() string

GetName Get name of entry.

func (*CommonServiceEntry) GetType added in v1.2.0

func (entry *CommonServiceEntry) GetType() string

GetType Get entry type.

func (*CommonServiceEntry) Git added in v1.2.0

func (entry *CommonServiceEntry) Git(ctx *gin.Context)

Git handler @Summary Get Git information. @Id 14 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @Security JWT @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)

Healthy handler @Summary Get application healthy status @Id 1 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @Security JWT @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)

Info handler @Summary Get application and process info @Id 3 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @Security JWT @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)

License handler @Summary Get license related application @Id 12 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @Security JWT @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)

Logs handler @Summary List logger related entries @Id 10 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @Security JWT @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)

MarshalJSON Marshal entry.

func (*CommonServiceEntry) Readme added in v1.2.0

func (entry *CommonServiceEntry) Readme(ctx *gin.Context)

Readme handler @Summary Get README file. @Id 13 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @Security JWT @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)

Req handler @Summary List prometheus metrics of requests @Id 7 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @Security JWT @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

String Stringfy entry.

func (*CommonServiceEntry) Sys added in v1.2.0

func (entry *CommonServiceEntry) Sys(ctx *gin.Context)

Sys handler @Summary Get OS Stat @Id 6 @version 1.0 @Security ApiKeyAuth @Security BasicAuth @Security JWT @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

UnmarshalJSON Not supported.

type CommonServiceEntryOption added in v1.2.0

type CommonServiceEntryOption func(*CommonServiceEntry)

CommonServiceEntryOption Common service entry option.

func WithEventLoggerEntryCommonService added in v1.2.0

func WithEventLoggerEntryCommonService(eventLoggerEntry *rkentry.EventLoggerEntry) CommonServiceEntryOption

WithEventLoggerEntryCommonService Provide rkentry.EventLoggerEntry.

func WithNameCommonService added in v1.2.0

func WithNameCommonService(name string) CommonServiceEntryOption

WithNameCommonService Provide name.

func WithZapLoggerEntryCommonService added in v1.2.0

func WithZapLoggerEntryCommonService(zapLoggerEntry *rkentry.ZapLoggerEntry) CommonServiceEntryOption

WithZapLoggerEntryCommonService 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"`
	StaticFileEntry    *StaticFileHandlerEntry   `json:"staticFileHandlerEntry" yaml:"staticFileHandlerEntry"`
	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

func GetGinEntry(name string) *GinEntry

GetGinEntry Get GinEntry from rkentry.GlobalAppCtx.

func RegisterGinEntry added in v1.2.0

func RegisterGinEntry(opts ...GinEntryOption) *GinEntry

RegisterGinEntry register GinEntry with options.

func (*GinEntry) AddInterceptor added in v1.2.0

func (entry *GinEntry) AddInterceptor(inters ...gin.HandlerFunc)

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

func (*GinEntry) Bootstrap

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

Bootstrap GinEntry.

func (*GinEntry) GetDescription added in v1.2.0

func (entry *GinEntry) GetDescription() string

GetDescription Get description of entry.

func (*GinEntry) GetName

func (entry *GinEntry) GetName() string

GetName Get entry name.

func (*GinEntry) GetType added in v1.1.3

func (entry *GinEntry) GetType() string

GetType Get entry type.

func (*GinEntry) Interrupt added in v1.2.0

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

Interrupt GinEntry.

func (*GinEntry) IsCommonServiceEnabled added in v1.2.0

func (entry *GinEntry) IsCommonServiceEnabled() bool

IsCommonServiceEnabled Is common service entry enabled?

func (*GinEntry) IsPromEnabled added in v1.2.0

func (entry *GinEntry) IsPromEnabled() bool

IsPromEnabled Is prometheus entry enabled?

func (*GinEntry) IsStaticFileHandlerEnabled added in v1.2.11

func (entry *GinEntry) IsStaticFileHandlerEnabled() bool

IsStaticFileHandlerEnabled Is static file handler entry enabled?

func (*GinEntry) IsSwEnabled added in v1.2.0

func (entry *GinEntry) IsSwEnabled() bool

IsSwEnabled Is swagger entry enabled?

func (*GinEntry) IsTlsEnabled added in v1.1.3

func (entry *GinEntry) IsTlsEnabled() bool

IsTlsEnabled Is TLS enabled?

func (*GinEntry) IsTvEnabled added in v1.2.0

func (entry *GinEntry) IsTvEnabled() bool

IsTvEnabled Is TV entry enabled?

func (*GinEntry) MarshalJSON added in v1.2.0

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

MarshalJSON Marshal entry.

func (*GinEntry) String added in v1.1.3

func (entry *GinEntry) String() string

String Stringfy gin entry.

func (*GinEntry) UnmarshalJSON added in v1.2.0

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

UnmarshalJSON Not supported.

type GinEntryOption

type GinEntryOption func(*GinEntry)

GinEntryOption Gin entry option.

func WithCertEntryGin added in v1.2.0

func WithCertEntryGin(certEntry *rkentry.CertEntry) GinEntryOption

WithCertEntryGin provide rkentry.CertEntry.

func WithCommonServiceEntryGin added in v1.2.0

func WithCommonServiceEntryGin(commonServiceEntry *CommonServiceEntry) GinEntryOption

WithCommonServiceEntryGin provide CommonServiceEntry.

func WithDescriptionGin added in v1.2.0

func WithDescriptionGin(description string) GinEntryOption

WithDescriptionGin provide name.

func WithEventLoggerEntryGin added in v1.2.0

func WithEventLoggerEntryGin(eventLogger *rkentry.EventLoggerEntry) GinEntryOption

WithEventLoggerEntryGin provide rkentry.EventLoggerEntry.

func WithInterceptorsGin added in v1.2.0

func WithInterceptorsGin(inters ...gin.HandlerFunc) GinEntryOption

WithInterceptorsGin provide user interceptors.

func WithNameGin added in v1.2.0

func WithNameGin(name string) GinEntryOption

WithNameGin provide name.

func WithPortGin added in v1.2.0

func WithPortGin(port uint64) GinEntryOption

WithPortGin provide port.

func WithPromEntryGin added in v1.2.0

func WithPromEntryGin(prom *PromEntry) GinEntryOption

WithPromEntryGin provide PromEntry.

func WithStaticFileHandlerEntryGin added in v1.2.11

func WithStaticFileHandlerEntryGin(staticEntry *StaticFileHandlerEntry) GinEntryOption

WithStaticFileHandlerEntryGin provide StaticFileHandlerEntry.

func WithSwEntryGin added in v1.2.0

func WithSwEntryGin(sw *SwEntry) GinEntryOption

WithSwEntryGin provide SwEntry.

func WithTVEntryGin added in v1.2.0

func WithTVEntryGin(tvEntry *TvEntry) GinEntryOption

WithTVEntryGin provide TvEntry.

func WithZapLoggerEntryGin added in v1.2.0

func WithZapLoggerEntryGin(zapLogger *rkentry.ZapLoggerEntry) GinEntryOption

WithZapLoggerEntryGin 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:"-"`
}

PromEntry 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

NewPromEntry Create a prom entry with options and add prom entry to rk_ctx.GlobalAppCtx

func (*PromEntry) Bootstrap added in v1.2.0

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

Bootstrap Start prometheus client

func (*PromEntry) GetDescription added in v1.2.0

func (entry *PromEntry) GetDescription() string

GetDescription Get description of entry

func (*PromEntry) GetName added in v1.2.0

func (entry *PromEntry) GetName() string

GetName Return name of prom entry

func (*PromEntry) GetType added in v1.2.0

func (entry *PromEntry) GetType() string

GetType Return type of prom entry

func (*PromEntry) Interrupt added in v1.2.0

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

Interrupt Shutdown prometheus client

func (*PromEntry) MarshalJSON added in v1.2.0

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

MarshalJSON Marshal entry

func (*PromEntry) RegisterCollectors added in v1.2.0

func (entry *PromEntry) RegisterCollectors(collectors ...prometheus.Collector) error

RegisterCollectors Register collectors in default registry

func (*PromEntry) String added in v1.2.0

func (entry *PromEntry) String() string

String Stringfy prom entry

func (*PromEntry) UnmarshalJSON added in v1.2.0

func (entry *PromEntry) UnmarshalJSON(b []byte) error

UnmarshalJSON Unmarshal entry

type PromEntryOption added in v1.2.0

type PromEntryOption func(*PromEntry)

PromEntryOption Prom entry option used while initializing prom entry via code

func WithEventLoggerEntryProm added in v1.2.0

func WithEventLoggerEntryProm(eventLoggerEntry *rkentry.EventLoggerEntry) PromEntryOption

WithEventLoggerEntryProm rkentry.EventLoggerEntry of prom entry

func WithNameProm added in v1.2.0

func WithNameProm(name string) PromEntryOption

WithNameProm Name of prom entry

func WithPathProm added in v1.2.0

func WithPathProm(path string) PromEntryOption

WithPathProm Path of prom entry

func WithPortProm added in v1.2.0

func WithPortProm(port uint64) PromEntryOption

WithPortProm Port of prom entry

func WithPromRegistryProm added in v1.2.0

func WithPromRegistryProm(registry *prometheus.Registry) PromEntryOption

WithPromRegistryProm Provide a new prometheus registry

func WithPusherProm added in v1.2.0

func WithPusherProm(pusher *rkprom.PushGatewayPusher) PromEntryOption

WithPusherProm PushGateway of prom entry

func WithZapLoggerEntryProm added in v1.2.0

func WithZapLoggerEntryProm(zapLoggerEntry *rkentry.ZapLoggerEntry) PromEntryOption

WithZapLoggerEntryProm rkentry.ZapLoggerEntry of prom entry

type StaticFileHandlerEntry added in v1.2.11

type StaticFileHandlerEntry struct {
	EntryName        string                    `yaml:"entryName" json:"entryName"`
	EntryType        string                    `yaml:"entryType" json:"entryType"`
	EntryDescription string                    `yaml:"entryDescription" json:"entryDescription"`
	Path             string                    `yaml:"path" json:"path"`
	EventLoggerEntry *rkentry.EventLoggerEntry `json:"-" yaml:"-"`
	ZapLoggerEntry   *rkentry.ZapLoggerEntry   `json:"-" yaml:"-"`
	Fs               http.FileSystem           `yaml:"-" json:"-"`
	Template         *template.Template        `json:"-" yaml:"-"`
}

StaticFileHandlerEntry Static file handler entry supports web UI for downloading static files.

func NewStaticFileHandlerEntry added in v1.2.11

func NewStaticFileHandlerEntry(opts ...StaticFileHandlerEntryOption) *StaticFileHandlerEntry

NewStaticFileHandlerEntry Create new static file handler entry with options.

func (*StaticFileHandlerEntry) Bootstrap added in v1.2.11

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

Bootstrap entry.

func (*StaticFileHandlerEntry) GetDescription added in v1.2.11

func (entry *StaticFileHandlerEntry) GetDescription() string

GetDescription Get description of entry.

func (*StaticFileHandlerEntry) GetFileHandler added in v1.2.11

func (entry *StaticFileHandlerEntry) GetFileHandler() gin.HandlerFunc

GetFileHandler handles requests sent from user.

func (*StaticFileHandlerEntry) GetName added in v1.2.11

func (entry *StaticFileHandlerEntry) GetName() string

GetName Get name of entry.

func (*StaticFileHandlerEntry) GetType added in v1.2.11

func (entry *StaticFileHandlerEntry) GetType() string

GetType Get entry type.

func (*StaticFileHandlerEntry) Interrupt added in v1.2.11

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

Interrupt entry.

func (*StaticFileHandlerEntry) MarshalJSON added in v1.2.11

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

MarshalJSON Marshal entry.

func (*StaticFileHandlerEntry) String added in v1.2.11

func (entry *StaticFileHandlerEntry) String() string

String Stringfy entry.

func (*StaticFileHandlerEntry) UnmarshalJSON added in v1.2.11

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

UnmarshalJSON Not supported.

type StaticFileHandlerEntryOption added in v1.2.11

type StaticFileHandlerEntryOption func(*StaticFileHandlerEntry)

StaticFileHandlerEntryOption StaticFileHandlerEntry option.

func WithEventLoggerEntryStatic added in v1.2.11

func WithEventLoggerEntryStatic(eventLoggerEntry *rkentry.EventLoggerEntry) StaticFileHandlerEntryOption

WithEventLoggerEntryCommonService Provide rkentry.EventLoggerEntry.

func WithFileSystemStatic added in v1.2.11

func WithFileSystemStatic(fs http.FileSystem) StaticFileHandlerEntryOption

WithFileSystemStatic Provide file system implementation.

func WithNameStatic added in v1.2.11

func WithNameStatic(name string) StaticFileHandlerEntryOption

WithNameStatic Provide name.

func WithPathStatic added in v1.2.11

func WithPathStatic(path string) StaticFileHandlerEntryOption

WithEventLoggerEntryCommonService Provide path.

func WithZapLoggerEntryStatic added in v1.2.11

func WithZapLoggerEntryStatic(zapLoggerEntry *rkentry.ZapLoggerEntry) StaticFileHandlerEntryOption

WithZapLoggerEntryCommonService Provide rkentry.ZapLoggerEntry.

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

func NewSwEntry(opts ...SwOption) *SwEntry

NewSwEntry Create new swagger entry with options.

func (*SwEntry) AssetsFileHandler added in v1.2.0

func (entry *SwEntry) AssetsFileHandler() gin.HandlerFunc

AssetsFileHandler Handler for swagger assets files.

func (*SwEntry) Bootstrap added in v1.2.0

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

Bootstrap swagger entry.

func (*SwEntry) ConfigFileHandler added in v1.2.0

func (entry *SwEntry) ConfigFileHandler() gin.HandlerFunc

ConfigFileHandler handler for swagger config files.

func (*SwEntry) GetDescription added in v1.2.0

func (entry *SwEntry) GetDescription() string

GetDescription Get description of entry

func (*SwEntry) GetName added in v1.2.0

func (entry *SwEntry) GetName() string

GetName Get name of entry.

func (*SwEntry) GetType added in v1.2.0

func (entry *SwEntry) GetType() string

GetType Get type of entry.

func (*SwEntry) Interrupt added in v1.2.0

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

Interrupt swagger entry.

func (*SwEntry) MarshalJSON added in v1.2.0

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

MarshalJSON Marshal entry

func (*SwEntry) String added in v1.2.0

func (entry *SwEntry) String() string

String Stringfy swagger entry

func (*SwEntry) UnmarshalJSON added in v1.2.0

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

UnmarshalJSON Unmarshal entry

type SwOption added in v1.2.0

type SwOption func(*SwEntry)

SwOption Swagger entry option.

func WithEnableCommonServiceSw added in v1.2.0

func WithEnableCommonServiceSw(enable bool) SwOption

WithEnableCommonServiceSw Provide enable common service option.

func WithEventLoggerEntrySw added in v1.2.0

func WithEventLoggerEntrySw(eventLoggerEntry *rkentry.EventLoggerEntry) SwOption

WithEventLoggerEntrySw Provide rkentry.EventLoggerEntry.

func WithHeadersSw added in v1.2.0

func WithHeadersSw(headers map[string]string) SwOption

WithHeadersSw Provide headers.

func WithJsonPathSw added in v1.2.0

func WithJsonPathSw(path string) SwOption

WithJsonPathSw Provide JsonPath.

func WithNameSw added in v1.2.0

func WithNameSw(name string) SwOption

WithNameSw Provide name.

func WithPathSw added in v1.2.0

func WithPathSw(path string) SwOption

WithPathSw Provide path.

func WithPortSw added in v1.2.0

func WithPortSw(port uint64) SwOption

WithPortSw Provide port.

func WithZapLoggerEntrySw added in v1.2.0

func WithZapLoggerEntrySw(zapLoggerEntry *rkentry.ZapLoggerEntry) SwOption

WithZapLoggerEntrySw 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:"-"`
}

TvEntry 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

NewTvEntry Create new TV entry with options.

func (*TvEntry) AssetsFileHandler added in v1.2.0

func (entry *TvEntry) AssetsFileHandler() gin.HandlerFunc

AssetsFileHandler Handler which returns js, css, images and html files for TV web UI.

func (*TvEntry) Bootstrap added in v1.2.0

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

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

func (entry *TvEntry) GetDescription() string

GetDescription Get description of entry.

func (*TvEntry) GetName added in v1.2.0

func (entry *TvEntry) GetName() string

GetName Get name of entry.

func (*TvEntry) GetType added in v1.2.0

func (entry *TvEntry) GetType() string

GetType Get type of entry.

func (*TvEntry) Interrupt added in v1.2.0

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

Interrupt TV entry.

func (*TvEntry) MarshalJSON added in v1.2.0

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

MarshalJSON Marshal entry

func (*TvEntry) String added in v1.2.0

func (entry *TvEntry) String() string

String Stringfy entry.

func (*TvEntry) TV added in v1.2.0

func (entry *TvEntry) TV(ctx *gin.Context)

TV handler @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

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

UnmarshalJSON Not supported.

type TvEntryOption added in v1.2.0

type TvEntryOption func(entry *TvEntry)

TvEntryOption TV entry option.

func WithEventLoggerEntryTv added in v1.2.0

func WithEventLoggerEntryTv(eventLoggerEntry *rkentry.EventLoggerEntry) TvEntryOption

WithEventLoggerEntryTv Provide rkentry.EventLoggerEntry.

func WithNameTv added in v1.2.0

func WithNameTv(name string) TvEntryOption

WithNameTv Provide name.

func WithZapLoggerEntryTv added in v1.2.0

func WithZapLoggerEntryTv(zapLoggerEntry *rkentry.ZapLoggerEntry) TvEntryOption

WithZapLoggerEntryTv Provide rkentry.ZapLoggerEntry.

Jump to

Keyboard shortcuts

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