rkgrpc

package
v1.2.8 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2021 License: Apache-2.0 Imports: 56 Imported by: 6

Documentation

Overview

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

Index

Constants

View Source
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"
)
View Source
const (
	// GrpcEntryType default entry type
	GrpcEntryType = "GrpcEntry"
	// GrpcEntryDescription default entry description
	GrpcEntryDescription = "Internal RK entry which helps to bootstrap with Grpc framework."
)
View Source
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."
)
View Source
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"
)
View Source
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

View Source
var (
	// RkGwServerMuxOptions RK style server mux
	RkGwServerMuxOptions = []runtime.ServeMuxOption{
		runtime.WithErrorHandler(HttpErrorHandler),
		runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.JSONPb{
			MarshalOptions: protojson.MarshalOptions{
				UseProtoNames:   false,
				EmitUnpopulated: true,
			},
			UnmarshalOptions: protojson.UnmarshalOptions{},
		}),
		runtime.WithMetadata(func(c context.Context, req *http.Request) metadata.MD {

			scheme := "http"
			if req.TLS != nil {
				scheme = "https"
			}

			return metadata.Pairs(
				"x-forwarded-method", req.Method,
				"x-forwarded-path", req.URL.Path,
				"x-forwarded-scheme", scheme,
				"x-forwarded-user-agent", req.UserAgent(),
				"x-forwarded-remote-addr", req.RemoteAddr)
		}),
		runtime.WithOutgoingHeaderMatcher(OutgoingHeaderMatcher),
		runtime.WithIncomingHeaderMatcher(IncomingHeaderMatcher),
	}
)
View Source
var (
	// Templates stores RK TV template as bytes
	Templates = map[string][]byte{}
)

Functions

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

func IncomingHeaderMatcher(key string) (string, bool)

IncomingHeaderMatcher Pass out all metadata in http header to grpc metadata.

func OutgoingHeaderMatcher added in v1.1.2

func OutgoingHeaderMatcher(key string) (string, bool)

OutgoingHeaderMatcher Pass out all metadata in grpc to http header.

func RegisterGrpcEntriesWithConfig added in v1.2.0

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

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"

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"`
		EnableRkGwOption   bool                    `yaml:"enableRkGwOption" json:"enableRkGwOption"`
		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"`
			Meta struct {
				Enabled bool   `yaml:"enabled" json:"enabled"`
				Prefix  string `yaml:"prefix" json:"prefix"`
			} `yaml:"meta" json:"meta"`
			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"`
			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.Logger.ZapLogger.Ref: Zap logger reference, see rkentry.ZapLoggerEntry for details. 45: Grpc.Logger.EventLogger.Ref: Event logger reference, see rkentry.EventLoggerEntry for details.

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 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:"entryDescription" yaml:"entryDescription"`
	EventLoggerEntry  *rkentry.EventLoggerEntry `json:"eventLoggerEntry" yaml:"eventLoggerEntry"`
	ZapLoggerEntry    *rkentry.ZapLoggerEntry   `json:"zapLoggerEntry" yaml:"zapLoggerEntry"`
	GrpcRegF          GrpcRegFunc               `json:"regFuncGrpc" yaml:"regFuncGrpc"`
	GwRegF            GwRegFunc                 `json:"regFuncGw" yaml:"regFuncGw"`
	GwMappingFilePath string                    `json:"gwMappingFilePath" yaml:"gwMappingFilePath"`
	GwMapping         map[string]string         `json:"gwMapping" yaml:"gwMapping"`
}

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(ctx 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:"entryDescription" yaml:"entryDescription"`
	ZapLoggerEntry    *rkentry.ZapLoggerEntry   `json:"zapLoggerEntry" yaml:"zapLoggerEntry"`
	EventLoggerEntry  *rkentry.EventLoggerEntry `json:"eventLoggerEntry" yaml:"eventLoggerEntry"`
	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:"swEntry" yaml:"swEntry"`
	TvEntry            *TvEntry            `json:"tvEntry" yaml:"tvEntry"`
	PromEntry          *PromEntry          `json:"promEntry" yaml:"promEntry"`
	CommonServiceEntry *CommonServiceEntry `json:"commonServiceEntry" yaml:"commonServiceEntry"`
	CertEntry          *rkentry.CertEntry  `json:"certEntry" yaml:"certEntry"`
}

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

func GetGrpcEntry(name string) *GrpcEntry

GetGrpcEntry Get GinEntry from rkentry.GlobalAppCtx.

func RegisterGrpcEntry added in v1.2.0

func RegisterGrpcEntry(opts ...GrpcEntryOption) *GrpcEntry

RegisterGrpcEntry Register GrpcEntry 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) 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

func (entry *GrpcEntry) AddRegFuncGw(f ...GwRegFunc)

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) Bootstrap added in v1.2.0

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

Bootstrap GrpcEntry.

func (*GrpcEntry) GetDescription added in v1.2.0

func (entry *GrpcEntry) GetDescription() string

GetDescription Get description of entry.

func (*GrpcEntry) GetName added in v1.2.0

func (entry *GrpcEntry) GetName() string

GetName Get entry name.

func (*GrpcEntry) GetType added in v1.2.0

func (entry *GrpcEntry) GetType() string

GetType Get entry type.

func (*GrpcEntry) Interrupt added in v1.2.0

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

Interrupt GrpcEntry.

func (*GrpcEntry) IsCommonServiceEnabled added in v1.2.0

func (entry *GrpcEntry) IsCommonServiceEnabled() bool

IsCommonServiceEnabled Is common service enabled?

func (*GrpcEntry) IsPromEnabled added in v1.2.3

func (entry *GrpcEntry) IsPromEnabled() bool

IsPromEnabled Is prometheus client enabled?

func (*GrpcEntry) IsSwEnabled added in v1.2.3

func (entry *GrpcEntry) IsSwEnabled() bool

IsSwEnabled Is swagger enabled?

func (*GrpcEntry) IsTlsEnabled added in v1.2.0

func (entry *GrpcEntry) IsTlsEnabled() bool

IsTlsEnabled Is TLS enabled?

func (*GrpcEntry) IsTvEnabled added in v1.2.3

func (entry *GrpcEntry) IsTvEnabled() bool

IsTvEnabled Is tv enabled?

func (*GrpcEntry) MarshalJSON added in v1.2.0

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

MarshalJSON Marshal entry.

func (*GrpcEntry) String added in v1.2.0

func (entry *GrpcEntry) String() string

String Stringfy entry.

func (*GrpcEntry) UnmarshalJSON added in v1.2.0

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

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

GwMuxOptions 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 WithServerOptionsGrpc added in v1.2.0

func WithServerOptionsGrpc(opts ...grpc.ServerOption) GrpcEntryOption

WithServerOptionsGrpc Provide grpc.ServerOption.

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

type GrpcRegFunc func(server *grpc.Server)

GrpcRegFunc Grpc registration func.

type GwRegFunc added in v1.2.0

GwRegFunc Registration function grpc gateway.

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 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.

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(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) 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(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

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(enabled bool) SwOption

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

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(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

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: 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

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 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(w http.ResponseWriter, r *http.Request)

TV Http handler of /rk/v1/tv/*.

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.

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.

Jump to

Keyboard shortcuts

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