# README
gRPC-Go with Polaris
English | 简体中文
Introduction
gRPC-Go-Polaris provides a series of components based on gRPC-Go framework, developers can use gRPC-Go-Polaris to build distributed gRPC-Go applications.
Key Features
- Service Registration and Heartbeat: To register the gRPC Service and send heartbeat periodly.
- Service Routing and LoadBalancing: Implement gRPC resover and balancer, providing semantic rule routing and loadbalacing cases.
- Fault node circuitbreaking: Kick of the unhealthy nodes when loadbalacing, base on the service invoke successful rate.
- RateLimiting: Implement gRPC interceptor, providing request ratelimit check to ensure the reliability for server.
Base Architecture
gRPC-Go-Polaris implements the interfaces on gRPC-Go, to access polarismesh functions.
How To Use
Prerequisites
- Go: any one of the three latest major releases.
Installation
With Go module support (Go 1.11+), simply add the following import
import "github.com/polarismesh/grpc-go-polaris"
to your code, and then go [build|run|test]
will automatically fetch the
necessary dependencies.
Otherwise, to install the grpc-go-polaris
package, run the following command:
$ go get -u github.com/polarismesh/grpc-go-polaris
Note: gRPC-Go-Polaris has
gRPC-Go
dependencies, it will encounter timeout while go gettinggRPC-Go
in China, to solution the problem, you can refer FAQ.
Examples
# Functions
BuildTarget build the invoker grpc target Deprecated: will remove in 1.4.
No description provided by the author
DialContext dial target and get connection.
No description provided by the author
NewRateLimitInterceptor creates a new RateLimitInterceptor.
No description provided by the author
NewServer start polaris server.
PolarisConfig get or init the global polaris configuration.
PolarisContext get or init the global polaris context.
Register server as polaris instances.
RegisterResolverInterceptor NOTE: this function must only be called during initialization time (i.e.
RequestScopeLbHashKey set request scope LbHashKey.
RequestScopeLbPolicy set request scope LbPolicy.
Serve start polaris server.
No description provided by the author
SetReportInfoAnalyzer sets report info analyzer.
WithClientNamespace set the namespace for dial service.
WithDelayRegisterEnable enables delay register.
WithDelayStopDisable disable delay stop Deprecated: will remove in 1.4.
WithDelayStopEnable enables delay stop Deprecated: will remove in 1.4.
WithDisableCircuitBreaker close polaris circuitbreaker ability.
WithDisableRouter close polaris route ability.
WithDstMetadata set the dstMetadata for dial service routing.
WithEnableCircuitBreaker open polaris circuitbreaker ability.
WithEnableRouter open polaris route ability.
WithGracefulStopDisable disable graceful stop.
WithGracefulStopEnable enables graceful stop.
WithGRPCDialOptions set the raw gRPC dialOption.
WithGRPCServerOptions set the raw gRPC serverOptions.
WithHeaderPrefix set the header filter to get the header values to routing Deprecated: will remove in 1.4.
WithHeartbeatEnable enables the heartbeat task to instance Deprecated: will remove in 1.4.
WithPolarisConfig set polaris configuration.
WithPolarisContext set polaris SDKContext.
WithPolarisLimit 开启北极星服务端限流能力.
WithPort set the port to register instance 该方法非必需调用, 建议只在注册端口和程序实际监听端口需要不一致时才调用.
WithSDKContext 设置用户自定义的北极星 SDKContext.
WithServerApplication set application name Deprecated: use WithServiceName to replace WithServerApplication.
WithServerHost set the host to register instance.
WithServerMetadata set the metadata to register instance.
WithServerNamespace set the namespace to register instance.
WithServerVersion set the version to register instance.
WithServiceName set the application to register instance.
WithSrcMetadata set the srcMetadata for dial service routing Deprecated: will remove in 1.4.
WithSrcService set the srcMetadata for dial service routing.
WithToken set the token to do server operations.
WithTTL set the ttl to register instance.
# Variables
DefaultDelayStopWaitDuration default delay time before stop.
DefaultGracefulStopMaxWaitDuration default stop max wait duration when not set.
DefaultNamespace default namespace when namespace is not set.
DefaultTTL default ttl value when ttl is not set.
ErrorPolarisServiceRouteRuleEmpty error service route rule is empty.
MinGracefulStopWaitDuration low bound of stop wait duration.
# Structs
LBConfig is the LB config for the polaris policy.
NoopDelayStrategy noop delay strategy.
RateLimitInterceptor is a gRPC interceptor that implements rate limiting.
No description provided by the author
Server encapsulated server with gRPC option.
WaitDelayStrategy wait delay strategy.
# Interfaces
DelayStrategy delay register strategy.
DialOption dialOptions for gRPC-Go-Polaris.
No description provided by the author
ResolverInterceptor 从 polaris sdk 拉取完 instances 执行过滤.
A ServerOption sets options such as credentials, codec and keepalive parameters, etc.
# Type aliases
No description provided by the author
No description provided by the author