polaris

package module
v1.2.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2022 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 3 Imported by: 43

README

polaris-go

English | 简体中文


Polaris is an operation centre that supports multiple programming languages, with high compatibility to different application framework. Polaris-go is golang SDK for Polaris.

Overview

Polaris-go provide features listed as below:

  • Service instance registration, and health check

    Provides API on/offline registration instance information, with regular report to inform caller server's healthy status.

  • Service discovery

    Provides multiple API, for users to get a full list of server instance, or get one server instance after route rule filtering and loadbalancing, which can be applied to srevice invocation soon.

  • Service circuitbreaking

    Provide API to report the invocation result, and conduct circuit breaker instance/group insolation based on collected data, eventually recover when the system allows.

  • Service ratelimiting

    Provides API for applications to conduct quota check and deduction, supports rate limit policies that are based on server level and port.

Quick Guide

Dependencies

polaris-go can be referenced by go mod, user can add dependency to go.mod file

github.com/polarismesh/polaris-go v1.0.0
Using API

API quick start guide,can reference:QuickStart

License

The polaris-go is licensed under the BSD 3-Clause License. Copyright and license information can be found in the file LICENSE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSDKContext added in v1.2.0

func NewSDKContext() (api.SDKContext, error)

func NewSDKContextByAddress added in v1.2.0

func NewSDKContextByAddress(address ...string) (api.SDKContext, error)

func NewSDKContextByConfig added in v1.2.0

func NewSDKContextByConfig(cfg config.Configuration) (api.SDKContext, error)

Types

type ConfigAPI

type ConfigAPI interface {
	api.SDKOwner
	// GetConfigFile 获取配置文件
	GetConfigFile(namespace, fileGroup, fileName string) (ConfigFile, error)
}

ConfigAPI 配置文件的 API

func NewConfigAPI

func NewConfigAPI() (ConfigAPI, error)

NewConfigAPI 获取配置中心 API

func NewConfigAPIByConfig

func NewConfigAPIByConfig(cfg config.Configuration) (ConfigAPI, error)

NewConfigAPIByConfig 通过配置对象获取配置中心 API

func NewConfigAPIByContext

func NewConfigAPIByContext(context api.SDKContext) ConfigAPI

NewConfigAPIByContext 通过上下文对象获取配置中心 API

func NewConfigAPIByFile

func NewConfigAPIByFile(path string) (ConfigAPI, error)

NewConfigAPIByFile 通过配置文件获取配置中心 API

type ConfigFile

type ConfigFile model.ConfigFile

type ConsumerAPI

type ConsumerAPI interface {
	api.SDKOwner
	// GetOneInstance 同步获取单个服务
	GetOneInstance(req *GetOneInstanceRequest) (*model.OneInstanceResponse, error)
	// GetInstances 同步获取可用的服务列表
	GetInstances(req *GetInstancesRequest) (*model.InstancesResponse, error)
	// GetAllInstances 同步获取完整的服务列表
	GetAllInstances(req *GetAllInstancesRequest) (*model.InstancesResponse, error)
	// GetRouteRule 同步获取服务路由规则
	GetRouteRule(req *GetServiceRuleRequest) (*model.ServiceRuleResponse, error)
	// UpdateServiceCallResult 上报服务调用结果
	UpdateServiceCallResult(req *ServiceCallResult) error
	// WatchService 订阅服务消息
	WatchService(req *WatchServiceRequest) (*model.WatchServiceResponse, error)
	// GetServicesByBusiness 根据业务同步获取批量服务
	GetServicesByBusiness(req *GetServicesRequest) (*model.ServicesResponse, error)
	// InitCalleeService 初始化服务运行中需要的被调服务
	InitCalleeService(req *InitCalleeServiceRequest) error
	// Destroy 销毁API,销毁后无法再进行调用
	Destroy()
}

ConsumerAPI 主调端API方法

func NewConsumerAPI

func NewConsumerAPI() (ConsumerAPI, error)

func NewConsumerAPIByAddress

func NewConsumerAPIByAddress(address ...string) (ConsumerAPI, error)

func NewConsumerAPIByConfig

func NewConsumerAPIByConfig(cfg config.Configuration) (ConsumerAPI, error)

func NewConsumerAPIByContext

func NewConsumerAPIByContext(context api.SDKContext) ConsumerAPI

func NewConsumerAPIByFile

func NewConsumerAPIByFile(path string) (ConsumerAPI, error)

type GetAllInstancesRequest

type GetAllInstancesRequest api.GetAllInstancesRequest

type GetInstancesRequest

type GetInstancesRequest api.GetInstancesRequest

type GetOneInstanceRequest

type GetOneInstanceRequest api.GetOneInstanceRequest

consumer API

type GetServiceRuleRequest

type GetServiceRuleRequest api.GetServiceRuleRequest

type GetServicesRequest

type GetServicesRequest api.GetServicesRequest

type InitCalleeServiceRequest

type InitCalleeServiceRequest api.InitCalleeServiceRequest

type InstanceDeRegisterRequest

type InstanceDeRegisterRequest api.InstanceDeRegisterRequest

type InstanceHeartbeatRequest

type InstanceHeartbeatRequest api.InstanceHeartbeatRequest

type InstanceRegisterRequest

type InstanceRegisterRequest api.InstanceRegisterRequest

provider

type LimitAPI

type LimitAPI interface {
	api.SDKOwner
	// GetQuota 获取限流配额,一次接口只获取一个配额
	GetQuota(request QuotaRequest) (QuotaFuture, error)
	// Destroy 销毁API,销毁后无法再进行调用
	Destroy()
}

LimitAPI 限流相关的API相关接口

func NewLimitAPI

func NewLimitAPI() (LimitAPI, error)

NewLimitAPI 通过以默认域名为埋点server的默认配置创建LimitAPI

func NewLimitAPIByAddress

func NewLimitAPIByAddress(address ...string) (LimitAPI, error)

func NewLimitAPIByConfig

func NewLimitAPIByConfig(cfg config.Configuration) (LimitAPI, error)

NewLimitAPIByConfig 通过配置对象创建SDK LimitAPI对象

func NewLimitAPIByContext

func NewLimitAPIByContext(context api.SDKContext) LimitAPI

NewLimitAPIByContext 通过上下文创建SDK LimitAPI对象

func NewLimitAPIByFile

func NewLimitAPIByFile(path string) (LimitAPI, error)

NewLimitAPIByFile 通过配置文件创建SDK LimitAPI对象

type ProcessLoadBalanceRequest added in v1.2.0

type ProcessLoadBalanceRequest struct {
	model.ProcessLoadBalanceRequest
}

type ProcessRoutersRequest added in v1.2.0

type ProcessRoutersRequest struct {
	model.ProcessRoutersRequest
}

type ProviderAPI

type ProviderAPI interface {
	api.SDKOwner
	// Register
	// 同步注册服务,服务注册成功后会填充instance中的InstanceID字段
	// 用户可保持该instance对象用于反注册和心跳上报
	Register(instance *InstanceRegisterRequest) (*model.InstanceRegisterResponse, error)
	// Deregister
	// 同步反注册服务
	Deregister(instance *InstanceDeRegisterRequest) error
	// Heartbeat
	// 心跳上报
	Heartbeat(instance *InstanceHeartbeatRequest) error
	// Destroy
	// 销毁API,销毁后无法再进行调用
	Destroy()
}

ProviderAPI CL5服务端API的主接口

func NewProviderAPI

func NewProviderAPI() (ProviderAPI, error)

NewProviderAPI 通过以默认域名为埋点server的默认配置创建ProviderAPI

func NewProviderAPIByAddress

func NewProviderAPIByAddress(address ...string) (ProviderAPI, error)

NewProviderAPIByAddress 通过address创建ProviderAPI

func NewProviderAPIByConfig

func NewProviderAPIByConfig(cfg config.Configuration) (ProviderAPI, error)

NewProviderAPIByConfig 通过配置对象创建SDK ProviderAPI对象

func NewProviderAPIByContext

func NewProviderAPIByContext(context api.SDKContext) ProviderAPI

NewProviderAPIByContext 通过上下文创建SDK ProviderAPI对象

func NewProviderAPIByFile

func NewProviderAPIByFile(path string) (ProviderAPI, error)

NewProviderAPIByFile 通过配置文件创建SDK ProviderAPI对象

type QuotaFuture

type QuotaFuture api.QuotaFuture

type QuotaRequest

type QuotaRequest api.QuotaRequest

rate limiter

func NewQuotaRequest

func NewQuotaRequest() QuotaRequest

NewQuotaRequest 创建配额查询请求

type RouterAPI added in v1.2.0

type RouterAPI interface {
	api.SDKOwner
	// process routers to filter instances
	ProcessRouters(*ProcessRoutersRequest) (*model.InstancesResponse, error)
	// process load balancer to get the target instances
	ProcessLoadBalance(*ProcessLoadBalanceRequest) (*model.OneInstanceResponse, error)
}

RouterAPI 路由API方法

func NewRouterAPI added in v1.2.0

func NewRouterAPI() (RouterAPI, error)

NewRouterAPI 通过以默认域名为埋点server的默认配置创建RouterAPI

func NewRouterAPIByAddress added in v1.2.0

func NewRouterAPIByAddress(address ...string) (RouterAPI, error)

NewRouterAPIByAddress 通过address创建RouterAPI

func NewRouterAPIByConfig added in v1.2.0

func NewRouterAPIByConfig(cfg config.Configuration) (RouterAPI, error)

newRouterAPIByConfig 通过配置对象创建SDK RouterAPI对象

func NewRouterAPIByContext added in v1.2.0

func NewRouterAPIByContext(context api.SDKContext) RouterAPI

NewRouterAPIByContext 通过上下文创建SDK RouterAPI对象

func NewRouterAPIByFile added in v1.2.0

func NewRouterAPIByFile(path string) (RouterAPI, error)

NewProviderAPIByFile 通过配置文件创建SDK RouterAPI对象

type ServiceCallResult

type ServiceCallResult api.ServiceCallResult

type WatchServiceRequest

type WatchServiceRequest api.WatchServiceRequest

Directories

Path Synopsis
benchmark
flags
Package flags provide convenience types and routines to accept specific types of flag values on the command line.
Package flags provide convenience types and routines to accept specific types of flag values on the command line.
stats
Package stats tracks the statistics associated with benchmark runs.
Package stats tracks the statistics associated with benchmark runs.
examples
pkg
log
model/pb/metric
Package metric is a generated protocol buffer package.
Package metric is a generated protocol buffer package.
plugin
serverconnector/sidecar/client
* * Tencent is pleased to support the open source community by making polaris-go available.
* * Tencent is pleased to support the open source community by making polaris-go available.
serverconnector/sidecar/dns
* * Tencent is pleased to support the open source community by making polaris-go available.
* * Tencent is pleased to support the open source community by making polaris-go available.
serverconnector/sidecar/model/pb
Package pb is a generated protocol buffer package.
Package pb is a generated protocol buffer package.
test
serviceroute
Package test mock test for set division * Tencent is pleased to support the open source community by making polaris-go available.
Package test mock test for set division * Tencent is pleased to support the open source community by making polaris-go available.
tools Module

Jump to

Keyboard shortcuts

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