Documentation
¶
Overview ¶
Package rkgrpc an implementation of rkentry.Entry which could be used start restful server with grpc framework
Experimental. This is used as grpc proxy server which forwarding grpc request to backend grpc server if not implemented. Currently, grpc-gateway and grpcurl is not supported. The grpc client called from code is supported.
Index ¶
- Constants
- Variables
- func Codec() encoding.Codec
- func CodecWithFallback(fallback encoding.Codec) encoding.Codec
- func HttpErrorHandler(ctx context.Context, mux *runtime.ServeMux, marshaler runtime.Marshaler, ...)
- func IncomingHeaderMatcher(key string) (string, bool)
- func NewRkGwServerMuxOptions(mOptIn *protojson.MarshalOptions, uOptIn *protojson.UnmarshalOptions) []runtime.ServeMuxOption
- func NewRule(opts ...ruleOption) *rule
- func OutgoingHeaderMatcher(key string) (string, bool)
- func RegisterGrpcEntriesWithConfig(configFilePath string) map[string]rkentry.Entry
- func TransparentHandler(director Director) grpc.StreamHandler
- func WithHeaderPatterns(pattern ...*HeaderPattern) ruleOption
- func WithIpPatterns(pattern ...*IpPattern) ruleOption
- func WithPathPatterns(pattern ...*PathPattern) ruleOption
- type BootConfigCommonService
- type BootConfigGrpc
- type BootConfigProm
- type BootConfigProxy
- type BootConfigStaticHandler
- type BootConfigSw
- type BootConfigTv
- type CommonServiceEntry
- func (entry *CommonServiceEntry) Apis(ctx context.Context, request *api.ApisRequest) (*structpb.Struct, error)
- func (entry *CommonServiceEntry) Bootstrap(context.Context)
- func (entry *CommonServiceEntry) Certs(ctx context.Context, request *api.CertsRequest) (*structpb.Struct, error)
- func (entry *CommonServiceEntry) Configs(ctx context.Context, request *api.ConfigsRequest) (*structpb.Struct, error)
- func (entry *CommonServiceEntry) Deps(ctx context.Context, request *api.DepsRequest) (*structpb.Struct, error)
- func (entry *CommonServiceEntry) Entries(ctx context.Context, request *api.EntriesRequest) (*structpb.Struct, error)
- func (entry *CommonServiceEntry) Gc(ctx context.Context, request *api.GcRequest) (*structpb.Struct, error)
- func (entry *CommonServiceEntry) GetDescription() string
- func (entry *CommonServiceEntry) GetName() string
- func (entry *CommonServiceEntry) GetType() string
- func (entry *CommonServiceEntry) Git(ctx context.Context, request *api.GitRequest) (*structpb.Struct, error)
- func (entry *CommonServiceEntry) GwErrorMapping(ctx context.Context, request *api.GwErrorMappingRequest) (*structpb.Struct, error)
- func (entry *CommonServiceEntry) Healthy(ctx context.Context, request *api.HealthyRequest) (*structpb.Struct, error)
- func (entry *CommonServiceEntry) Info(ctx context.Context, request *api.InfoRequest) (*structpb.Struct, error)
- func (entry *CommonServiceEntry) Interrupt(ctx context.Context)
- func (entry *CommonServiceEntry) License(ctx context.Context, request *api.LicenseRequest) (*structpb.Struct, error)
- func (entry *CommonServiceEntry) Logs(ctx context.Context, request *api.LogsRequest) (*structpb.Struct, error)
- func (entry *CommonServiceEntry) MarshalJSON() ([]byte, error)
- func (entry *CommonServiceEntry) Readme(ctx context.Context, request *api.ReadmeRequest) (*structpb.Struct, error)
- func (entry *CommonServiceEntry) Req(ctx context.Context, request *api.ReqRequest) (*structpb.Struct, error)
- func (entry *CommonServiceEntry) String() string
- func (entry *CommonServiceEntry) Sys(ctx context.Context, request *api.SysRequest) (*structpb.Struct, error)
- func (entry *CommonServiceEntry) UnmarshalJSON([]byte) error
- type CommonServiceEntryOption
- type Director
- type GrpcEntry
- func (entry *GrpcEntry) AddGwCorsOptions(opts ...rkgrpccors.Option)
- func (entry *GrpcEntry) AddGwCsrfOptions(opts ...rkgrpccsrf.Option)
- func (entry *GrpcEntry) AddGwDialOptions(opts ...grpc.DialOption)
- func (entry *GrpcEntry) AddGwSecureOptions(opts ...rkgrpcsec.Option)
- func (entry *GrpcEntry) AddRegFuncGrpc(f ...GrpcRegFunc)
- func (entry *GrpcEntry) AddRegFuncGw(f ...GwRegFunc)
- func (entry *GrpcEntry) AddServerOptions(opts ...grpc.ServerOption)
- func (entry *GrpcEntry) AddStreamInterceptors(inter ...grpc.StreamServerInterceptor)
- func (entry *GrpcEntry) AddUnaryInterceptors(inter ...grpc.UnaryServerInterceptor)
- func (entry *GrpcEntry) Bootstrap(ctx context.Context)
- func (entry *GrpcEntry) GetDescription() string
- func (entry *GrpcEntry) GetName() string
- func (entry *GrpcEntry) GetType() string
- func (entry *GrpcEntry) Interrupt(ctx context.Context)
- func (entry *GrpcEntry) IsCommonServiceEnabled() bool
- func (entry *GrpcEntry) IsPromEnabled() bool
- func (entry *GrpcEntry) IsProxyEnabled() bool
- func (entry *GrpcEntry) IsStaticFileHandlerEnabled() bool
- func (entry *GrpcEntry) IsSwEnabled() bool
- func (entry *GrpcEntry) IsTlsEnabled() bool
- func (entry *GrpcEntry) IsTvEnabled() bool
- func (entry *GrpcEntry) MarshalJSON() ([]byte, error)
- func (entry *GrpcEntry) String() string
- func (entry *GrpcEntry) UnmarshalJSON([]byte) error
- type GrpcEntryOption
- func WithCertEntryGrpc(certEntry *rkentry.CertEntry) GrpcEntryOption
- func WithCommonServiceEntryGrpc(commonService *CommonServiceEntry) GrpcEntryOption
- func WithDescriptionGrpc(description string) GrpcEntryOption
- func WithEnableReflectionGrpc(enabled bool) GrpcEntryOption
- func WithEventLoggerEntryGrpc(logger *rkentry.EventLoggerEntry) GrpcEntryOption
- func WithGrpcDialOptionsGrpc(opts ...grpc.DialOption) GrpcEntryOption
- func WithGrpcRegF(f ...GrpcRegFunc) GrpcEntryOption
- func WithGwMappingFilePathsGrpc(paths ...string) GrpcEntryOption
- func WithGwMuxOptionsGrpc(opts ...gwruntime.ServeMuxOption) GrpcEntryOption
- func WithGwRegFGrpc(f ...GwRegFunc) GrpcEntryOption
- func WithNameGrpc(name string) GrpcEntryOption
- func WithPortGrpc(port uint64) GrpcEntryOption
- func WithPromEntryGrpc(prom *PromEntry) GrpcEntryOption
- func WithProxyEntryGrpc(proxy *ProxyEntry) GrpcEntryOption
- func WithServerOptionsGrpc(opts ...grpc.ServerOption) GrpcEntryOption
- func WithStaticFileHandlerEntryGrpc(staticEntry *StaticFileHandlerEntry) GrpcEntryOption
- func WithStreamInterceptorsGrpc(opts ...grpc.StreamServerInterceptor) GrpcEntryOption
- func WithSwEntryGrpc(sw *SwEntry) GrpcEntryOption
- func WithTvEntryGrpc(tv *TvEntry) GrpcEntryOption
- func WithUnaryInterceptorsGrpc(opts ...grpc.UnaryServerInterceptor) GrpcEntryOption
- func WithZapLoggerEntryGrpc(logger *rkentry.ZapLoggerEntry) GrpcEntryOption
- type GrpcRegFunc
- type GwRegFunc
- type HeaderPattern
- type IpPattern
- type PathPattern
- 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 ProxyEntry
- func (entry *ProxyEntry) Bootstrap(ctx context.Context)
- func (entry *ProxyEntry) GetDescription() string
- func (entry *ProxyEntry) GetName() string
- func (entry *ProxyEntry) GetType() string
- func (entry *ProxyEntry) Interrupt(ctx context.Context)
- func (entry *ProxyEntry) MarshalJSON() ([]byte, error)
- func (entry *ProxyEntry) String() string
- func (entry *ProxyEntry) UnmarshalJSON(b []byte) error
- type ProxyEntryOption
- type StaticFileHandlerEntry
- func (entry *StaticFileHandlerEntry) Bootstrap(ctx context.Context)
- func (entry *StaticFileHandlerEntry) GetDescription() string
- func (entry *StaticFileHandlerEntry) GetFileHandler(w http.ResponseWriter, r *http.Request)
- func (entry *StaticFileHandlerEntry) GetName() string
- func (entry *StaticFileHandlerEntry) GetType() string
- func (entry *StaticFileHandlerEntry) Interrupt(ctx context.Context)
- func (entry *StaticFileHandlerEntry) MarshalJSON() ([]byte, error)
- func (entry *StaticFileHandlerEntry) String() string
- func (entry *StaticFileHandlerEntry) UnmarshalJSON([]byte) error
- type StaticFileHandlerEntryOption
- func WithEventLoggerEntryStatic(eventLoggerEntry *rkentry.EventLoggerEntry) StaticFileHandlerEntryOption
- func WithFileSystemStatic(fs http.FileSystem) StaticFileHandlerEntryOption
- func WithNameStatic(name string) StaticFileHandlerEntryOption
- func WithPathStatic(path string) StaticFileHandlerEntryOption
- func WithZapLoggerEntryStatic(zapLoggerEntry *rkentry.ZapLoggerEntry) StaticFileHandlerEntryOption
- type SwEntry
- func (entry *SwEntry) AssetsFileHandler(w http.ResponseWriter, r *http.Request)
- func (entry *SwEntry) Bootstrap(ctx context.Context)
- func (entry *SwEntry) ConfigFileHandler(w http.ResponseWriter, r *http.Request)
- 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(enabled 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(w http.ResponseWriter, r *http.Request)
- 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(w http.ResponseWriter, r *http.Request)
- func (entry *TvEntry) UnmarshalJSON([]byte) error
- type TvEntryOption
Constants ¶
const ( // CommonServiceEntryType default entry type CommonServiceEntryType = "GrpcCommonServiceEntry" // CommonServiceEntryNameDefault default entry name CommonServiceEntryNameDefault = "GrpcCommonServiceDefault" // CommonServiceEntryDescription default entry description CommonServiceEntryDescription = "Internal RK entry which implements commonly used API with grpc framework." // CommonServiceGwMappingFilePath default path for gw_mapping.yaml file CommonServiceGwMappingFilePath = "api/v1/gw_mapping.yaml" )
const ( // GrpcEntryType default entry type GrpcEntryType = "GrpcEntry" // GrpcEntryDescription default entry description GrpcEntryDescription = "Internal RK entry which helps to bootstrap with Grpc framework." )
const ( // PromEntryType default entry type PromEntryType = "GrpcPromEntry" // PromEntryNameDefault default entry name PromEntryNameDefault = "GrpcPromDefault" // PromEntryDescription default entry description PromEntryDescription = "Internal RK entry which implements prometheus client with Grpc framework." )
const ( // ProxyEntryType default entry type ProxyEntryType = "ProxyEntry" // ProxyEntryNameDefault default entry name ProxyEntryNameDefault = "ProxyDefault" // ProxyEntryDescription default entry description ProxyEntryDescription = "Internal RK entry which implements proxy with Grpc framework." // HeaderBased header based proxy pattern HeaderBased = "headerBased" // PathBased grpc path(method) based proxy pattern PathBased = "pathBased" // IpBased remote IP based proxy pattern IpBased = "ipBased" )
const ( // StaticFileHandlerEntryType type of entry StaticFileHandlerEntryType = "GrpcStaticFileHandlerEntry" // StaticFileHandlerEntryNameDefault name of entry StaticFileHandlerEntryNameDefault = "GrpcStaticFileHandlerDefault" // StaticFileHandlerEntryDescription description of entry StaticFileHandlerEntryDescription = "Internal RK entry which implements static file handler Grpc framework." )
const ( // SwEntryType default entry type SwEntryType = "GrpcSwEntry" // SwEntryNameDefault default entry name SwEntryNameDefault = "GrpcSwDefault" // SwEntryDescription default entry description SwEntryDescription = "Internal RK entry which implements swagger with Grpc framework." // SwEntryCommonServiceJsonFileSuffix default swagger json file suffix SwEntryCommonServiceJsonFileSuffix = "-rk-common.swagger.json" )
const ( // TvEntryType default entry type TvEntryType = "GrpcTvEntry" // TvEntryNameDefault default entry name TvEntryNameDefault = "GrpcTvDefault" // TvEntryDescription default entry description TvEntryDescription = "Internal RK entry which implements tv web with grpc framework." )
Variables ¶
var ( // Templates stores RK TV template as bytes Templates = map[string][]byte{} )
Functions ¶
func Codec ¶ added in v1.2.10
Codec returns a proxying grpc.Codec with the default protobuf codec as parent.
See CodecWithParent.
func CodecWithFallback ¶ added in v1.2.10
CodecWithParent returns a proxying grpc.Codec with a user provided codec as parent.
This codec is *crucial* to the functioning of the proxy. It allows the proxy server to be oblivious to the schema of the forwarded messages. It basically treats a gRPC message frame as raw bytes. However, if the server handler, or the client caller are not proxy-internal functions it will fall back to trying to decode the message using a fallback codec.
func HttpErrorHandler ¶ added in v1.2.0
func HttpErrorHandler(ctx context.Context, mux *runtime.ServeMux, marshaler runtime.Marshaler, w http.ResponseWriter, r *http.Request, err error)
HttpErrorHandler Mainly copies from runtime.DefaultHTTPErrorHandler. We reformat error response with rkerror.ErrorResp.
func IncomingHeaderMatcher ¶ added in v1.2.0
IncomingHeaderMatcher Pass out all metadata in http header to grpc metadata.
func NewRkGwServerMuxOptions ¶ added in v1.2.11
func NewRkGwServerMuxOptions(mOptIn *protojson.MarshalOptions, uOptIn *protojson.UnmarshalOptions) []runtime.ServeMuxOption
NewRkGwServerMuxOptions creates new gw server mux options.
func NewRule ¶ added in v1.2.10
func NewRule(opts ...ruleOption) *rule
NewRule create a new proxy rules with options.
func OutgoingHeaderMatcher ¶ added in v1.1.2
OutgoingHeaderMatcher Pass out all metadata in grpc to http header.
func RegisterGrpcEntriesWithConfig ¶ added in v1.2.0
RegisterGrpcEntriesWithConfig Register grpc 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"
func TransparentHandler ¶ added in v1.2.10
func TransparentHandler(director Director) grpc.StreamHandler
TransparentHandler returns a handler that attempts to proxy all requests that are not registered in the server. The indented use here is as a transparent proxy, where the server doesn't know about the services implemented by the backends. It should be used as a `grpc.UnknownServiceHandler`.
This can *only* be used if the `server` also uses grpcproxy.CodecForServer() ServerOption.
func WithHeaderPatterns ¶ added in v1.2.10
func WithHeaderPatterns(pattern ...*HeaderPattern) ruleOption
WithHeaderPatterns provide header based patterns.
func WithIpPatterns ¶ added in v1.2.10
func WithIpPatterns(pattern ...*IpPattern) ruleOption
WithIpPatterns provide IP based patterns.
func WithPathPatterns ¶ added in v1.2.10
func WithPathPatterns(pattern ...*PathPattern) ruleOption
WithPathPatterns provide path based patterns.
Types ¶
type BootConfigCommonService ¶ added in v1.2.0
type BootConfigCommonService struct {
Enabled bool `yaml:"enabled"`
}
BootConfigCommonService Bootstrap config of common service. 1: Enabled: Enable common service.
type BootConfigGrpc ¶ added in v1.2.0
type BootConfigGrpc struct { Grpc []struct { Name string `yaml:"name" json:"name"` Description string `yaml:"description" json:"description"` Port uint64 `yaml:"port" json:"port"` Enabled bool `yaml:"enabled" json:"enabled"` EnableReflection bool `yaml:"enableReflection" json:"enableReflection"` NoRecvMsgSizeLimit bool `yaml:"noRecvMsgSizeLimit" json:"noRecvMsgSizeLimit"` Cert struct { Ref string `yaml:"ref" json:"ref"` } `yaml:"cert" json:"cert"` CommonService BootConfigCommonService `yaml:"commonService" json:"commonService"` Sw BootConfigSw `yaml:"sw" json:"sw"` Tv BootConfigTv `yaml:"tv" json:"tv"` Prom BootConfigProm `yaml:"prom" json:"prom"` Static BootConfigStaticHandler `yaml:"static" json:"static"` Proxy BootConfigProxy `yaml:"proxy" json:"proxy"` EnableRkGwOption bool `yaml:"enableRkGwOption" json:"enableRkGwOption"` GwOption *gwOption `yaml:"gwOption" json:"gwOption"` GwMappingFilePaths []string `yaml:"gwMappingFilePaths" json:"gwMappingFilePaths"` 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"` 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"` 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"` 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"` 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"` 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:"grpc" json:"grpc"` }
BootConfigGrpc Boot config which is for grpc entry.
1: Grpc.Name: Name of entry, should be unique globally. 2: Grpc.Description: Description of entry. 3: Grpc.Enabled: Enable GrpcEntry. 4: Grpc.Port: Port of entry. 5: Grpc.EnableReflection: Enable gRPC reflection or not. 6: Grpc.Cert.Ref: Reference of rkentry.CertEntry. 7: Grpc.CommonService.Enabled: Reference of CommonService. 8: Grpc.Sw.Enabled: Enable SwEntry. 9: Grpc.Sw.Path: Swagger UI path. 10: Grpc.Sw.JsonPath: Swagger JSON config file path. 11: Grpc.Sw.Headers: Http headers which would be forwarded to user. 12: Grpc.Tv.Enabled: Enable TvEntry. 13: Grpc.Prom.Pusher.Enabled: Enable prometheus pushgateway pusher. 14: Grpc.Prom.Pusher.IntervalMs: Interval in milliseconds while pushing metrics to remote pushGateway. 15: Grpc.Prom.Pusher.JobName: Name of pushGateway pusher job. 16: Grpc.Prom.Pusher.RemoteAddress: Remote address of pushGateway server. 17: Grpc.Prom.Pusher.BasicAuth: Basic auth credential of pushGateway server. 18: Grpc.Prom.Pusher.Cert.Ref: Reference of rkentry.CertEntry. 19: Grpc.Prom.Cert.Ref: Reference of rkentry.CertEntry. 20: Grpc.Interceptors.LoggingZap.Enabled: Enable zap logger interceptor. 21: Grpc.Interceptors.LoggingZap.ZapLoggerEncoding: json or console. 22: Grpc.Interceptors.LoggingZap.ZapLoggerOutputPaths: Output paths, stdout is supported. 23: Grpc.Interceptors.LoggingZap.EventLoggerEncoding: json or console. 24: Grpc.Interceptors.LoggingZap.EventLoggerOutputPaths: Output paths, stdout is supported. 25: Grpc.Interceptors.MetricsProm.Enabled: Enable prometheus metrics interceptor. 26: Grpc.Interceptors.Auth.Enabled: Enable basic auth interceptor. 27: Grpc.Interceptors.Auth.Basic: Basic auth credentials as scheme of <user:pass>. 28: Grpc.Interceptors.Auth.ApiKey: API key auth type. 29: Grpc.Interceptors.Auth.IgnorePrefix: The prefix that ignoring auth. 30: Grpc.Interceptors.Meta.Enabled: Meta interceptor which attach meta headers to response. 31: Grpc.Interceptors.Meta.Prefix: Meta interceptor which attach meta headers to response with prefix. 32: Grpc.Interceptors.Meta.TracingTelemetry.Enabled: Tracing interceptor. 33: Grpc.Interceptors.Meta.TracingTelemetry.Exporter.File.Enabled: Tracing interceptor with file as exporter. 34: Grpc.Interceptors.Meta.TracingTelemetry.Exporter.File.OutputPath: Exporter output paths. 35: Grpc.Interceptors.Meta.TracingTelemetry.Exporter.Jaeger.Enabled: Tracing interceptor with jaeger as exporter. 36: Grpc.Interceptors.Meta.TracingTelemetry.Exporter.Jaeger.CollectorEndpoint: Jaeger collector endpoint. 37: Grpc.Interceptors.Meta.TracingTelemetry.Exporter.Jaeger.CollectorUsername: Jaeger collector user name. 38: Grpc.Interceptors.Meta.TracingTelemetry.Exporter.Jaeger.CollectorPassword: Jaeger collector password. 39: Grpc.Interceptors.RateLimit.Enabled: Enable rate limit interceptor. 40: Grpc.Interceptors.RateLimit.Algorithm: Algorithm of rate limiter. 41: Grpc.Interceptors.RateLimit.ReqPerSec: Request per second. 42: Grpc.Interceptors.RateLimit.Paths.Path: Name of gRPC full method. 43: Grpc.Interceptors.RateLimit.Paths.ReqPerSec: Request per second by method. 44: Grpc.Interceptors.Timeout.Enabled: Enable timeout interceptor. 45: Grpc.Interceptors.Timeout.TimeoutMs: Timeout in milliseconds. 46: Grpc.Interceptors.Timeout.Paths.path: Name of full path. 47: Grpc.Interceptors.Timeout.Paths.TimeoutMs: Timeout in milliseconds by path. 48: Grpc.Logger.ZapLogger.Ref: Zap logger reference, see rkentry.ZapLoggerEntry for details. 49: Grpc.Logger.EventLogger.Ref: Event logger reference, see rkentry.EventLoggerEntry for details. 50: Grpc.GwOption.Marshal.Multiline: Enable multiline in gateway option. 51: Grpc.GwOption.Marshal.EmitUnpopulated: Enable emitUnpopulated in gateway option. 52: Grpc.GwOption.Marshal.Indent: Set indent in gateway option. 53: Grpc.GwOption.Marshal.AllowPartial: Enable allowPartial in gateway option. 54: Grpc.GwOption.Marshal.UseProtoNames: Enable useProtoNames in gateway option. 55: Grpc.GwOption.Marshal.UseEnumNumbers: Enable useEnumNumbers in gateway option. 56: Grpc.GwOption.Unmarshal.AllowPartial: Enable allowPartial in gateway option. 57: Grpc.GwOption.Unmarshal.DiscardUnknown: Enable discardUnknown in gateway option.
type BootConfigProm ¶ added in v1.2.0
type BootConfigProm struct { Enabled bool `yaml:"enabled" json:"enabled"` Path string `yaml:"path" json:"path"` Pusher struct { Enabled bool `yaml:"enabled" json:"enabled"` JobName string `yaml:"jobName" json:"jobName"` RemoteAddress string `yaml:"remoteAddress" json:"remoteAddress"` IntervalMs int64 `yaml:"IntervalMs" json:"IntervalMs"` 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.
type BootConfigProxy ¶ added in v1.2.10
type BootConfigProxy struct { Enabled bool `yaml:"enabled" json:"enabled"` Rules []struct { Type string `yaml:"type" json:"type"` HeaderPairs []string `yaml:"headerPairs" json:"headerPairs"` Dest []string `yaml:"dest" json:"dest"` Paths []string `yaml:"paths" json:"paths"` Ips []string `yaml:"ips" json:"ips"` } `yaml:"rules" json:"rules"` }
BootConfigProxy Boot config which is for proxy entry.
1: Enabled: Enable prom entry. 2: Rules: Provide rules for proxying.
type BootConfigStaticHandler ¶ added in v1.2.13
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" json:"enabled"` Path string `yaml:"path" json:"path"` JsonPath string `yaml:"jsonPath" json:"jsonPath"` Headers []string `yaml:"headers" json:"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:"-" yaml:"-"` EventLoggerEntry *rkentry.EventLoggerEntry `json:"-" yaml:"-"` ZapLoggerEntry *rkentry.ZapLoggerEntry `json:"-" yaml:"-"` GrpcRegF GrpcRegFunc `json:"-" yaml:"-"` GwRegF GwRegFunc `json:"-" yaml:"-"` GwMappingFilePath string `json:"gwMappingFilePath" yaml:"gwMappingFilePath"` GwMapping map[string]string `json:"-" yaml:"-"` }
CommonServiceEntry RK common service which contains commonly used APIs 1: Healthy GET Returns true if process is alive 2: Gc GET Trigger gc() 3: Info GET Returns entry basic information 4: Configs GET Returns viper configs in GlobalAppCtx 5: Apis GET Returns list of apis registered in gin router 6: Sys GET Returns CPU and Memory information 7: Req GET Returns request metrics 8: Certs GET Returns certificates 9: Entries GET Returns entries
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 context.Context, request *api.ApisRequest) (*structpb.Struct, error)
Apis Stub
func (*CommonServiceEntry) Bootstrap ¶ added in v1.2.0
func (entry *CommonServiceEntry) Bootstrap(context.Context)
Bootstrap common service entry
func (*CommonServiceEntry) Certs ¶ added in v1.2.0
func (entry *CommonServiceEntry) Certs(ctx context.Context, request *api.CertsRequest) (*structpb.Struct, error)
Certs Stub
func (*CommonServiceEntry) Configs ¶ added in v1.2.0
func (entry *CommonServiceEntry) Configs(ctx context.Context, request *api.ConfigsRequest) (*structpb.Struct, error)
Configs Stub.
func (*CommonServiceEntry) Deps ¶ added in v1.2.0
func (entry *CommonServiceEntry) Deps(ctx context.Context, request *api.DepsRequest) (*structpb.Struct, error)
Deps Stub
func (*CommonServiceEntry) Entries ¶ added in v1.2.0
func (entry *CommonServiceEntry) Entries(ctx context.Context, request *api.EntriesRequest) (*structpb.Struct, error)
Entries Stub
func (*CommonServiceEntry) Gc ¶ added in v1.2.0
func (entry *CommonServiceEntry) Gc(ctx context.Context, request *api.GcRequest) (*structpb.Struct, error)
Gc Stub.
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 context.Context, request *api.GitRequest) (*structpb.Struct, error)
Git Stub
func (*CommonServiceEntry) GwErrorMapping ¶ added in v1.2.0
func (entry *CommonServiceEntry) GwErrorMapping(ctx context.Context, request *api.GwErrorMappingRequest) (*structpb.Struct, error)
GwErrorMapping Get error mapping file contents.
func (*CommonServiceEntry) Healthy ¶ added in v1.2.0
func (entry *CommonServiceEntry) Healthy(ctx context.Context, request *api.HealthyRequest) (*structpb.Struct, error)
Healthy Stub.
func (*CommonServiceEntry) Info ¶ added in v1.2.0
func (entry *CommonServiceEntry) Info(ctx context.Context, request *api.InfoRequest) (*structpb.Struct, error)
Info Stub.
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 context.Context, request *api.LicenseRequest) (*structpb.Struct, error)
License Stub
func (*CommonServiceEntry) Logs ¶ added in v1.2.0
func (entry *CommonServiceEntry) Logs(ctx context.Context, request *api.LogsRequest) (*structpb.Struct, error)
Logs Stub
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 context.Context, request *api.ReadmeRequest) (*structpb.Struct, error)
Readme Get README file contents.
func (*CommonServiceEntry) Req ¶ added in v1.2.0
func (entry *CommonServiceEntry) Req(ctx context.Context, request *api.ReqRequest) (*structpb.Struct, error)
Req Stub
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 context.Context, request *api.SysRequest) (*structpb.Struct, error)
Sys Stub
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 function.
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 GrpcEntry ¶ added in v1.2.0
type GrpcEntry struct { EntryName string `json:"entryName" yaml:"entryName"` EntryType string `json:"entryType" yaml:"entryType"` EntryDescription string `json:"-" yaml:"-"` ZapLoggerEntry *rkentry.ZapLoggerEntry `json:"-" yaml:"-"` EventLoggerEntry *rkentry.EventLoggerEntry `json:"-" yaml:"-"` Port uint64 `json:"port" yaml:"port"` TlsConfig *tls.Config `json:"-" yaml:"-"` TlsConfigInsecure *tls.Config `json:"-" yaml:"-"` // GRPC related Server *grpc.Server `json:"-" yaml:"-"` ServerOpts []grpc.ServerOption `json:"-" yaml:"-"` UnaryInterceptors []grpc.UnaryServerInterceptor `json:"-" yaml:"-"` StreamInterceptors []grpc.StreamServerInterceptor `json:"-" yaml:"-"` GrpcRegF []GrpcRegFunc `json:"-" yaml:"-"` EnableReflection bool `json:"enableReflection" yaml:"enableReflection"` // Gateway related HttpMux *http.ServeMux `json:"-" yaml:"-"` HttpServer *http.Server `json:"-" yaml:"-"` GwMux *gwruntime.ServeMux `json:"-" yaml:"-"` GwMuxOptions []gwruntime.ServeMuxOption `json:"-" yaml:"-"` GwRegF []GwRegFunc `json:"-" yaml:"-"` GwMappingFilePaths []string `json:"gwMappingFilePaths" yaml:"gwMappingFilePaths"` GwDialOptions []grpc.DialOption `json:"-" yaml:"-"` GwHttpToGrpcMapping map[string]*gwRule `json:"gwMapping" yaml:"gwMapping"` // Utility related SwEntry *SwEntry `json:"-" yaml:"-"` TvEntry *TvEntry `json:"-" yaml:"-"` ProxyEntry *ProxyEntry `json:"-" yaml:"-"` PromEntry *PromEntry `json:"-" yaml:"-"` StaticFileEntry *StaticFileHandlerEntry `json:"-" yaml:"-"` CommonServiceEntry *CommonServiceEntry `json:"-" yaml:"-"` CertEntry *rkentry.CertEntry `json:"-" yaml:"-"` // contains filtered or unexported fields }
GrpcEntry implements rkentry.Entry interface.
1: EntryName: Name of entry 2: EntryType: Type of entry 3: EntryDescription: Description of entry 4: ZapLoggerEntry: See rkentry.ZapLoggerEntry for details. 5: EventLoggerEntry: See rkentry.EventLoggerEntry for details. 6: Port: http/https port server listen to. 7: TlsConfig: TLS config for http and grpc server 8: TlsConfigInsecure: TLS config for grpc client of gateway 9: Server: gRPC server created while bootstrapping. 10: ServerOpts: Server options for grpc server. 11: UnaryInterceptors: Interceptors user enabled. 12: StreamInterceptors: Interceptors user enabled. 13: GrpcRegF: gRPC registration functions. 14: HttpMux: http mux for overall http server 15: HttpServer: http server over grpc server 16: GwMux: gRPC gateway mux only routes http requests over grpc 17: GwMuxOptions: gRPC gateway mux options. 18: GwRegF: gRPC gateway registration function which generated from protocol buffer 19: GwMappingFilePaths: gRPC gateway to grpc method mapping file paths. 20: GwHttpToGrpcMapping: gRPC gateway to grpc method mapping. 21: SwEntry: Swagger entry. 22: TvEntry: RK tv entry. 23: PromEntry: Prometheus client entry. 24: CommonServiceEntry: CommonService entry. 25: CertEntry: See CertEntry for details.
func GetGrpcEntry ¶ added in v1.2.0
GetGrpcEntry Get GrpcEntry from rkentry.GlobalAppCtx.
func RegisterGrpcEntry ¶ added in v1.2.0
func RegisterGrpcEntry(opts ...GrpcEntryOption) *GrpcEntry
RegisterGrpcEntry Register GrpcEntry with options.
func (*GrpcEntry) AddGwCorsOptions ¶ added in v1.2.12
func (entry *GrpcEntry) AddGwCorsOptions(opts ...rkgrpccors.Option)
AddGwCorsOptions Enable CORS at gateway side with options.
func (*GrpcEntry) AddGwCsrfOptions ¶ added in v1.2.13
func (entry *GrpcEntry) AddGwCsrfOptions(opts ...rkgrpccsrf.Option)
AddGwCsrfOptions Enable CORS at gateway side with options.
func (*GrpcEntry) AddGwDialOptions ¶ added in v1.2.3
func (entry *GrpcEntry) AddGwDialOptions(opts ...grpc.DialOption)
AddGwDialOptions Add grpc dial options called from grpc gateway
func (*GrpcEntry) AddGwSecureOptions ¶ added in v1.2.13
AddGwSecureOptions Enable secure at gateway side with options.
func (*GrpcEntry) AddRegFuncGrpc ¶ added in v1.2.3
func (entry *GrpcEntry) AddRegFuncGrpc(f ...GrpcRegFunc)
AddRegFuncGrpc Add grpc registration func.
func (*GrpcEntry) AddRegFuncGw ¶ added in v1.2.3
AddRegFuncGw Add gateway registration func.
func (*GrpcEntry) AddServerOptions ¶ added in v1.2.0
func (entry *GrpcEntry) AddServerOptions(opts ...grpc.ServerOption)
AddServerOptions Add grpc server options.
func (*GrpcEntry) AddStreamInterceptors ¶ added in v1.2.0
func (entry *GrpcEntry) AddStreamInterceptors(inter ...grpc.StreamServerInterceptor)
AddStreamInterceptors Add stream interceptor.
func (*GrpcEntry) AddUnaryInterceptors ¶ added in v1.2.0
func (entry *GrpcEntry) AddUnaryInterceptors(inter ...grpc.UnaryServerInterceptor)
AddUnaryInterceptors Add unary interceptor.
func (*GrpcEntry) GetDescription ¶ added in v1.2.0
GetDescription Get description of entry.
func (*GrpcEntry) IsCommonServiceEnabled ¶ added in v1.2.0
IsCommonServiceEnabled Is common service enabled?
func (*GrpcEntry) IsPromEnabled ¶ added in v1.2.3
IsPromEnabled Is prometheus client enabled?
func (*GrpcEntry) IsProxyEnabled ¶ added in v1.2.10
IsProxyEnabled Is proxy enabled?
func (*GrpcEntry) IsStaticFileHandlerEnabled ¶ added in v1.2.13
IsStaticFileHandlerEnabled Is static file handler entry enabled?
func (*GrpcEntry) IsSwEnabled ¶ added in v1.2.3
IsSwEnabled Is swagger enabled?
func (*GrpcEntry) IsTlsEnabled ¶ added in v1.2.0
IsTlsEnabled Is TLS enabled?
func (*GrpcEntry) IsTvEnabled ¶ added in v1.2.3
IsTvEnabled Is tv enabled?
func (*GrpcEntry) MarshalJSON ¶ added in v1.2.0
MarshalJSON Marshal entry.
func (*GrpcEntry) UnmarshalJSON ¶ added in v1.2.0
UnmarshalJSON Not supported.
type GrpcEntryOption ¶ added in v1.2.0
type GrpcEntryOption func(*GrpcEntry)
GrpcEntryOption GrpcEntry option.
func WithCertEntryGrpc ¶ added in v1.2.0
func WithCertEntryGrpc(certEntry *rkentry.CertEntry) GrpcEntryOption
WithCertEntryGrpc Provide rkentry.CertEntry.
func WithCommonServiceEntryGrpc ¶ added in v1.2.0
func WithCommonServiceEntryGrpc(commonService *CommonServiceEntry) GrpcEntryOption
WithCommonServiceEntryGrpc Provide CommonServiceEntry.
func WithDescriptionGrpc ¶ added in v1.2.0
func WithDescriptionGrpc(description string) GrpcEntryOption
WithDescriptionGrpc Provide description.
func WithEnableReflectionGrpc ¶ added in v1.2.0
func WithEnableReflectionGrpc(enabled bool) GrpcEntryOption
WithEnableReflectionGrpc Provide EnableReflection.
func WithEventLoggerEntryGrpc ¶ added in v1.2.0
func WithEventLoggerEntryGrpc(logger *rkentry.EventLoggerEntry) GrpcEntryOption
WithEventLoggerEntryGrpc Provide rkentry.EventLoggerEntry
func WithGrpcDialOptionsGrpc ¶ added in v1.2.3
func WithGrpcDialOptionsGrpc(opts ...grpc.DialOption) GrpcEntryOption
WithGrpcDialOptionsGrpc Provide grpc dial options.
func WithGrpcRegF ¶ added in v1.2.3
func WithGrpcRegF(f ...GrpcRegFunc) GrpcEntryOption
WithGrpcRegF Provide GrpcRegFunc.
func WithGwMappingFilePathsGrpc ¶ added in v1.2.3
func WithGwMappingFilePathsGrpc(paths ...string) GrpcEntryOption
WithGwMappingFilePathsGrpc Provide gateway mapping configuration file paths.
func WithGwMuxOptionsGrpc ¶ added in v1.2.3
func WithGwMuxOptionsGrpc(opts ...gwruntime.ServeMuxOption) GrpcEntryOption
WithGwMuxOptionsGrpc Provide gateway server mux options.
func WithGwRegFGrpc ¶ added in v1.2.3
func WithGwRegFGrpc(f ...GwRegFunc) GrpcEntryOption
WithGwRegFGrpc Provide registration function.
func WithNameGrpc ¶ added in v1.2.0
func WithNameGrpc(name string) GrpcEntryOption
WithNameGrpc Provide name.
func WithPortGrpc ¶ added in v1.2.0
func WithPortGrpc(port uint64) GrpcEntryOption
WithPortGrpc Provide port.
func WithPromEntryGrpc ¶ added in v1.2.3
func WithPromEntryGrpc(prom *PromEntry) GrpcEntryOption
WithPromEntryGrpc Provide PromEntry.
func WithProxyEntryGrpc ¶ added in v1.2.10
func WithProxyEntryGrpc(proxy *ProxyEntry) GrpcEntryOption
WithProxyEntryGrpc Provide ProxyEntry.
func WithServerOptionsGrpc ¶ added in v1.2.0
func WithServerOptionsGrpc(opts ...grpc.ServerOption) GrpcEntryOption
WithServerOptionsGrpc Provide grpc.ServerOption.
func WithStaticFileHandlerEntryGrpc ¶ added in v1.2.13
func WithStaticFileHandlerEntryGrpc(staticEntry *StaticFileHandlerEntry) GrpcEntryOption
WithStaticFileHandlerEntryGrpc provide StaticFileHandlerEntry.
func WithStreamInterceptorsGrpc ¶ added in v1.2.0
func WithStreamInterceptorsGrpc(opts ...grpc.StreamServerInterceptor) GrpcEntryOption
WithStreamInterceptorsGrpc Provide grpc.StreamServerInterceptor.
func WithSwEntryGrpc ¶ added in v1.2.3
func WithSwEntryGrpc(sw *SwEntry) GrpcEntryOption
WithSwEntryGrpc Provide SwEntry.
func WithTvEntryGrpc ¶ added in v1.2.3
func WithTvEntryGrpc(tv *TvEntry) GrpcEntryOption
WithTvEntryGrpc Provide TvEntry.
func WithUnaryInterceptorsGrpc ¶ added in v1.2.0
func WithUnaryInterceptorsGrpc(opts ...grpc.UnaryServerInterceptor) GrpcEntryOption
WithUnaryInterceptorsGrpc Provide grpc.UnaryServerInterceptor.
func WithZapLoggerEntryGrpc ¶ added in v1.2.0
func WithZapLoggerEntryGrpc(logger *rkentry.ZapLoggerEntry) GrpcEntryOption
WithZapLoggerEntryGrpc Provide rkentry.ZapLoggerEntry
type GrpcRegFunc ¶ added in v1.2.0
GrpcRegFunc Grpc registration func.
type HeaderPattern ¶ added in v1.2.10
HeaderPattern defines proxy rules based on header.
Proxy will validate headers in metadata with provided rules.
type IpPattern ¶ added in v1.2.10
IpPattern defines proxy rules based on remote IPs.
Ip rule support CIDR.
type PathPattern ¶ added in v1.2.10
PathPattern defines proxy rules based on path.
The incoming path should match with rules. Path rule support regex.
type PromEntry ¶ added in v1.2.0
type PromEntry struct { Pusher *rkprom.PushGatewayPusher `json:"-" yaml:"-"` EntryName string `json:"entryName" yaml:"entryName"` EntryType string `json:"entryType" yaml:"entryType"` EntryDescription string `json:"-" yaml:"-"` ZapLoggerEntry *rkentry.ZapLoggerEntry `json:"-" yaml:"-"` EventLoggerEntry *rkentry.EventLoggerEntry `json:"-" yaml:"-"` 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) GetDescription ¶ added in v1.2.0
GetDescription Get description of entry
func (*PromEntry) MarshalJSON ¶ added in v1.2.0
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) UnmarshalJSON ¶ added in v1.2.0
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 ProxyEntry ¶ added in v1.2.10
type ProxyEntry struct { EntryName string `json:"entryName" yaml:"entryName"` EntryType string `json:"entryType" yaml:"entryType"` EntryDescription string `json:"-" yaml:"-"` ZapLoggerEntry *rkentry.ZapLoggerEntry `json:"-" yaml:"-"` EventLoggerEntry *rkentry.EventLoggerEntry `json:"-" yaml:"-"` // contains filtered or unexported fields }
func NewProxyEntry ¶ added in v1.2.10
func NewProxyEntry(opts ...ProxyEntryOption) *ProxyEntry
NewProxyEntry Create a proxy entry with options
func (*ProxyEntry) Bootstrap ¶ added in v1.2.10
func (entry *ProxyEntry) Bootstrap(ctx context.Context)
Bootstrap Start prometheus client
func (*ProxyEntry) GetDescription ¶ added in v1.2.10
func (entry *ProxyEntry) GetDescription() string
GetDescription Get description of entry
func (*ProxyEntry) GetName ¶ added in v1.2.10
func (entry *ProxyEntry) GetName() string
GetName Return name of proxy entry
func (*ProxyEntry) GetType ¶ added in v1.2.10
func (entry *ProxyEntry) GetType() string
GetType Return type of prom entry
func (*ProxyEntry) Interrupt ¶ added in v1.2.10
func (entry *ProxyEntry) Interrupt(ctx context.Context)
Interrupt Shutdown prometheus client
func (*ProxyEntry) MarshalJSON ¶ added in v1.2.10
func (entry *ProxyEntry) MarshalJSON() ([]byte, error)
MarshalJSON Marshal entry
func (*ProxyEntry) String ¶ added in v1.2.10
func (entry *ProxyEntry) String() string
String Stringfy prom entry
func (*ProxyEntry) UnmarshalJSON ¶ added in v1.2.10
func (entry *ProxyEntry) UnmarshalJSON(b []byte) error
UnmarshalJSON Unmarshal entry
type ProxyEntryOption ¶ added in v1.2.10
type ProxyEntryOption func(*ProxyEntry)
ProxyEntryOption Proxy entry option used while initializing proxy entry via code
func WithEventLoggerEntryProxy ¶ added in v1.2.10
func WithEventLoggerEntryProxy(eventLoggerEntry *rkentry.EventLoggerEntry) ProxyEntryOption
WithEventLoggerEntryProxy rkentry.EventLoggerEntry of proxy entry
func WithNameProxy ¶ added in v1.2.10
func WithNameProxy(name string) ProxyEntryOption
WithNameProm Name of proxy entry
func WithRuleProxy ¶ added in v1.2.10
func WithRuleProxy(r *rule) ProxyEntryOption
WithRuleProxy Provide rule
func WithZapLoggerEntryProxy ¶ added in v1.2.10
func WithZapLoggerEntryProxy(zapLoggerEntry *rkentry.ZapLoggerEntry) ProxyEntryOption
WithZapLoggerEntryProxy rkentry.ZapLoggerEntry of proxy entry
type StaticFileHandlerEntry ¶ added in v1.2.13
type StaticFileHandlerEntry struct { EntryName string `yaml:"entryName" json:"entryName"` EntryType string `yaml:"entryType" json:"entryType"` EntryDescription string `yaml:"-" json:"-"` 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.13
func NewStaticFileHandlerEntry(opts ...StaticFileHandlerEntryOption) *StaticFileHandlerEntry
NewStaticFileHandlerEntry Create new static file handler entry with options.
func (*StaticFileHandlerEntry) Bootstrap ¶ added in v1.2.13
func (entry *StaticFileHandlerEntry) Bootstrap(ctx context.Context)
Bootstrap entry.
func (*StaticFileHandlerEntry) GetDescription ¶ added in v1.2.13
func (entry *StaticFileHandlerEntry) GetDescription() string
GetDescription Get description of entry.
func (*StaticFileHandlerEntry) GetFileHandler ¶ added in v1.2.13
func (entry *StaticFileHandlerEntry) GetFileHandler(w http.ResponseWriter, r *http.Request)
GetFileHandler handles requests sent from user.
func (*StaticFileHandlerEntry) GetName ¶ added in v1.2.13
func (entry *StaticFileHandlerEntry) GetName() string
GetName Get name of entry.
func (*StaticFileHandlerEntry) GetType ¶ added in v1.2.13
func (entry *StaticFileHandlerEntry) GetType() string
GetType Get entry type.
func (*StaticFileHandlerEntry) Interrupt ¶ added in v1.2.13
func (entry *StaticFileHandlerEntry) Interrupt(ctx context.Context)
Interrupt entry.
func (*StaticFileHandlerEntry) MarshalJSON ¶ added in v1.2.13
func (entry *StaticFileHandlerEntry) MarshalJSON() ([]byte, error)
MarshalJSON Marshal entry.
func (*StaticFileHandlerEntry) String ¶ added in v1.2.13
func (entry *StaticFileHandlerEntry) String() string
String Stringfy entry.
func (*StaticFileHandlerEntry) UnmarshalJSON ¶ added in v1.2.13
func (entry *StaticFileHandlerEntry) UnmarshalJSON([]byte) error
UnmarshalJSON Not supported.
type StaticFileHandlerEntryOption ¶ added in v1.2.13
type StaticFileHandlerEntryOption func(*StaticFileHandlerEntry)
StaticFileHandlerEntryOption StaticFileHandlerEntry option.
func WithEventLoggerEntryStatic ¶ added in v1.2.13
func WithEventLoggerEntryStatic(eventLoggerEntry *rkentry.EventLoggerEntry) StaticFileHandlerEntryOption
WithEventLoggerEntryCommonService Provide rkentry.EventLoggerEntry.
func WithFileSystemStatic ¶ added in v1.2.13
func WithFileSystemStatic(fs http.FileSystem) StaticFileHandlerEntryOption
WithFileSystemStatic Provide file system implementation.
func WithNameStatic ¶ added in v1.2.13
func WithNameStatic(name string) StaticFileHandlerEntryOption
WithNameStatic Provide name.
func WithPathStatic ¶ added in v1.2.13
func WithPathStatic(path string) StaticFileHandlerEntryOption
WithEventLoggerEntryCommonService Provide path.
func WithZapLoggerEntryStatic ¶ added in v1.2.13
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:"-" yaml:"-"` EventLoggerEntry *rkentry.EventLoggerEntry `json:"-" yaml:"-"` ZapLoggerEntry *rkentry.ZapLoggerEntry `json:"-" yaml:"-"` 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.
func NewSwEntry ¶ added in v1.2.0
NewSwEntry Create new swagger entry with options.
func (*SwEntry) AssetsFileHandler ¶ added in v1.2.0
func (entry *SwEntry) AssetsFileHandler(w http.ResponseWriter, r *http.Request)
AssetsFileHandler Http handler which handles assets files of swagger web UI with path prefix of /rk/v1/*
func (*SwEntry) ConfigFileHandler ¶ added in v1.2.0
func (entry *SwEntry) ConfigFileHandler(w http.ResponseWriter, r *http.Request)
ConfigFileHandler Http handler which handles swagger.json files with prefix of SwEntry.Path/*
func (*SwEntry) GetDescription ¶ added in v1.2.0
GetDescription Get description of entry.
func (*SwEntry) MarshalJSON ¶ added in v1.2.0
MarshalJSON Marshal entry
func (*SwEntry) UnmarshalJSON ¶ added in v1.2.0
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
WithEnableCommonServiceSw Provide rkentry.EventLoggerEntry.
func WithEventLoggerEntrySw ¶ added in v1.2.0
func WithEventLoggerEntrySw(eventLoggerEntry *rkentry.EventLoggerEntry) SwOption
WithEventLoggerEntrySw Provide rkentry.EventLoggerEntry.
func WithHeadersSw ¶ added in v1.2.0
WithHeadersSw Provide headers.
func WithJsonPathSw ¶ added in v1.2.0
WithJsonPathSw Provide JsonPath.
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:"-" yaml:"-"` ZapLoggerEntry *rkentry.ZapLoggerEntry `json:"-" yaml:"-"` EventLoggerEntry *rkentry.EventLoggerEntry `json:"-" yaml:"-"` 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(w http.ResponseWriter, r *http.Request)
AssetsFileHandler 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: api.tmpl 8: entry.tmpl 9: config.tmpl 10: cert.tmpl 11: os.tmpl 12: env.tmpl 13: prometheus.tmpl 14: log.tmpl 15: dep.tmpl 16: license.tmpl 17: info.tmpl
func (*TvEntry) GetDescription ¶ added in v1.2.0
GetDescription Get description of entry.
func (*TvEntry) MarshalJSON ¶ added in v1.2.0
MarshalJSON Marshal entry
func (*TvEntry) TV ¶ added in v1.2.0
func (entry *TvEntry) TV(w http.ResponseWriter, r *http.Request)
TV Http handler of /rk/v1/tv/*.
func (*TvEntry) UnmarshalJSON ¶ added in v1.2.0
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.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
api
|
|
third_party/gen/v1
Package rk_grpc_common_v1 is a reverse proxy.
|
Package rk_grpc_common_v1 is a reverse proxy. |