├── version ├── plugin ├── history │ └── README.md ├── password │ ├── README.md │ └── parse.go ├── ratelimit │ ├── README.md │ └── token │ │ ├── limiter.go │ │ ├── log.go │ │ ├── register.go │ │ └── invoke.go ├── textexport.go ├── log.go ├── statis │ ├── logger │ │ └── log.go │ └── prometheus │ │ └── config_handle.go ├── sync.go ├── healthchecker │ └── leader │ │ ├── log.go │ │ └── config.go ├── plugin_test.go ├── whitelist.go └── password.go ├── apiserver ├── README.md ├── httpserver │ ├── i18n │ │ └── README.md │ ├── default.go │ ├── log.go │ ├── config │ │ └── log.go │ └── discover │ │ ├── v1 │ │ └── log.go │ │ └── v2 │ │ ├── log.go │ │ └── proto.go ├── nacosserver │ ├── v1 │ │ ├── log.go │ │ └── config │ │ │ ├── log.go │ │ │ └── config_file_test.go │ ├── v2 │ │ ├── log.go │ │ ├── config │ │ │ └── log.go │ │ ├── remote │ │ │ └── log.go │ │ ├── discover │ │ │ └── log.go │ │ └── pb │ │ │ └── nacos_grpc_service.proto │ ├── core │ │ └── log.go │ ├── model │ │ ├── event.go │ │ └── error.go │ ├── default.go │ └── logger │ │ └── log.go ├── l5pbserver │ ├── log.go │ └── default.go ├── xdsserverv3 │ ├── cache │ │ └── log.go │ ├── log.go │ ├── resource │ │ └── log.go │ └── default.go ├── grpcserver │ ├── config │ │ └── default.go │ └── discover │ │ └── default.go └── eurekaserver │ ├── default.go │ ├── log.go │ └── eureka_suit_test.go ├── test ├── chaosmesh │ └── README.md ├── benchmark │ └── grpc │ │ ├── heartbeat │ │ └── README.md │ │ └── client │ │ └── benchmark.md ├── suit │ └── README.md ├── tools │ ├── go.mod │ ├── tools_vet.go │ └── tools.go ├── outlier │ ├── README.md │ ├── backend │ │ └── Dockerfile │ ├── frontend │ │ └── Dockerfile │ └── build.sh ├── integrate │ ├── strategy_test.go │ ├── group_test.go │ ├── user_test.go │ ├── http │ │ └── user.go │ ├── grpc │ │ ├── config_center.go │ │ ├── heartbeat.go │ │ └── report_client.go │ └── resource │ │ └── client.go └── data │ └── testdata.go ├── qrcode.png ├── cache ├── mock │ └── README.md ├── auth │ ├── policy_test.go │ ├── log.go │ └── default.go ├── api │ └── log.go ├── log.go ├── gray │ └── log.go ├── config │ ├── default.go │ ├── log.go │ └── config_group_metrics.go ├── service │ ├── log.go │ └── default.go ├── client │ └── client_metrics.go └── config.go ├── release ├── standalone │ ├── docker │ │ ├── prometheus │ │ │ ├── Dockerfile │ │ │ ├── build_docker_prom.sh │ │ │ └── prometheus.yml │ │ └── Dockerfile │ ├── docker-compose │ │ ├── prometheus │ │ │ ├── Dockerfile │ │ │ └── prometheus.yml │ │ ├── mysql │ │ │ ├── mysqld.cnf │ │ │ └── Dockerfile │ │ ├── grafana │ │ │ ├── Dockerfile │ │ │ ├── grafana.ini │ │ │ └── provisioning │ │ │ │ ├── dashboards │ │ │ │ └── dashboard.yml │ │ │ │ └── datasources │ │ │ │ └── datasource.yml │ │ ├── README.md │ │ ├── limiter │ │ │ └── polaris-limiter.yaml │ │ └── console │ │ │ └── polaris-console.yaml │ ├── port.properties │ ├── prometheus-help.sh │ └── windows │ │ ├── run.bat │ │ ├── install.bat │ │ ├── stop.bat │ │ └── uninstall.bat ├── cluster │ ├── helm │ │ ├── images │ │ │ └── polaris.png │ │ ├── templates │ │ │ ├── polaris-namespace.yaml │ │ │ ├── config-polaris-console.yaml │ │ │ ├── polaris-limiter.yaml │ │ │ └── config-prometheus.yaml │ │ ├── Chart.yaml │ │ └── .helmignore │ └── kubernetes │ │ ├── 00-polaris-namespace.yaml │ │ ├── 01-polaris-console-config.yaml │ │ ├── 07-polaris-limiter.yaml │ │ └── 04-prometheus-config.yaml ├── upgrade │ └── circuitbreaker_rule_transform │ │ ├── go.mod │ │ ├── README.md │ │ └── go.sum ├── tool │ ├── p.bat │ ├── stop.bat │ ├── stop.sh │ ├── p.sh │ ├── check.sh │ └── start.sh ├── README-zh.md ├── Dockerfile ├── README.md └── conf │ └── plugin │ └── ratelimit │ └── rule.yaml ├── auth ├── mock │ └── README.md ├── user │ ├── log.go │ └── inteceptor │ │ └── auth │ │ └── log.go ├── policy │ ├── inteceptor │ │ └── auth │ │ │ └── log.go │ ├── action_map.go │ ├── log.go │ └── test_export.go └── testexport.go ├── .github ├── ISSUE_TEMPLATE │ ├── q-a.md │ ├── documentation.md │ ├── feature_request.md │ └── bug_report.md ├── pull_request_template.md └── workflows │ ├── licence-checker.yml │ ├── weekly-report.yml │ └── golangci-lint.yml ├── Code-of-Conduct.md ├── .gitignore ├── store ├── mock │ └── README.md ├── boltdb │ ├── circuitbreaker_test.go │ ├── log.go │ ├── tool.go │ ├── l5_test.go │ └── tx.go ├── mysql │ ├── log.go │ ├── common_test.go │ ├── scripts │ │ └── delta │ │ │ └── v1_14_0-v1_17_0.sql │ ├── sql_test.go │ └── tx.go ├── sql.go └── test_export.go ├── service ├── utils_test.go ├── batch │ ├── log.go │ └── client_future_test.go ├── healthcheck │ ├── log.go │ └── test_export.go ├── log.go ├── interceptor │ ├── auth │ │ ├── log.go │ │ └── l5_service.go │ └── paramcheck │ │ └── cl5.go └── l5_service_test.go ├── common ├── model │ ├── auth │ │ └── context.go │ ├── http.go │ ├── context_key.go │ └── gray.go ├── conn │ ├── limit │ │ └── stats.go │ └── hook │ │ └── conn.go ├── hash │ └── fnv32.go ├── utils │ ├── funcs_test.go │ ├── reflect.go │ ├── atomic.go │ └── context.go ├── version │ └── version.go └── srand │ └── scalable_rand_test.go ├── main.go ├── admin ├── log.go ├── interceptor │ └── auth │ │ └── log.go ├── job │ └── config.go ├── config.go └── server.go ├── namespace ├── interceptor │ └── auth │ │ └── log.go └── log.go ├── config ├── log.go ├── interceptor │ ├── auth │ │ └── log.go │ └── paramcheck │ │ └── log.go └── options.go ├── cmd ├── root.go ├── start.go └── version.go └── bootstrap └── run_windows.go /version: -------------------------------------------------------------------------------- 1 | v1.19.0-alpha.0 -------------------------------------------------------------------------------- /plugin/history/README.md: -------------------------------------------------------------------------------- 1 | # 操作记录插件 -------------------------------------------------------------------------------- /plugin/password/README.md: -------------------------------------------------------------------------------- 1 | # 密码插件 -------------------------------------------------------------------------------- /apiserver/README.md: -------------------------------------------------------------------------------- 1 | # API Server 2 | -------------------------------------------------------------------------------- /plugin/ratelimit/README.md: -------------------------------------------------------------------------------- 1 | # 访问频率限制 2 | -------------------------------------------------------------------------------- /test/chaosmesh/README.md: -------------------------------------------------------------------------------- 1 | # ChaosMesh -- 北极星故障场景测试 -------------------------------------------------------------------------------- /apiserver/httpserver/i18n/README.md: -------------------------------------------------------------------------------- 1 | ```bash 2 | go run cmd/gen.go 3 | ``` -------------------------------------------------------------------------------- /qrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polarismesh/polaris/HEAD/qrcode.png -------------------------------------------------------------------------------- /cache/mock/README.md: -------------------------------------------------------------------------------- 1 | mockgen -source=api/types.go -destination=mock/cache_mock.go -package=mock -------------------------------------------------------------------------------- /release/standalone/docker/prometheus/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM prom/prometheus 2 | ADD prometheus.yml /etc/prometheus/ -------------------------------------------------------------------------------- /release/cluster/helm/images/polaris.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polarismesh/polaris/HEAD/release/cluster/helm/images/polaris.png -------------------------------------------------------------------------------- /release/cluster/kubernetes/00-polaris-namespace.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: polaris-system 5 | -------------------------------------------------------------------------------- /release/standalone/docker-compose/prometheus/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM polarismesh/prometheus:latest 2 | ADD prometheus.yml /etc/prometheus/ -------------------------------------------------------------------------------- /release/standalone/docker-compose/mysql/mysqld.cnf: -------------------------------------------------------------------------------- 1 | [mysqld] 2 | character-set-server=utf8mb4 3 | collation-server=utf8mb4_unicode_ci 4 | -------------------------------------------------------------------------------- /test/benchmark/grpc/heartbeat/README.md: -------------------------------------------------------------------------------- 1 | # Benchmark Heartbeat 2 | 3 | 本测试仅用于测试 heartbeatLeader 插件下的心跳上报场景 4 | 5 | ## 测试场景 6 | 7 | #### 8 | 9 | -------------------------------------------------------------------------------- /auth/mock/README.md: -------------------------------------------------------------------------------- 1 | # 对Auth的API的mock 2 | 3 | ## mock文件生成方法 4 | 5 | ``` 6 | mockgen -source=api.go -destination=./mock/api_mock.go -package=mock 7 | ``` -------------------------------------------------------------------------------- /release/cluster/helm/templates/polaris-namespace.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: {{ .Values.installation.namespace }} 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/q-a.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Q&A 3 | about: Please tell me your questions 4 | title: '' 5 | labels: question 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /release/cluster/helm/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | appVersion: "1.0" 3 | description: A Helm chart for polaris 4 | name: polaris 5 | version: v1.17.3 6 | maintainers: 7 | - name: trezhang 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/documentation.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Documentation 3 | about: Improvements or additions to documentation 4 | title: '' 5 | labels: documentation 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /release/standalone/docker-compose/grafana/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM grafana/grafana 2 | 3 | 4 | # Disable Login form or not 5 | ENV GF_AUTH_DISABLE_LOGIN_FORM "true" 6 | # Allow anonymous authentication or not 7 | ENV GF_AUTH_ANONYMOUS_ENABLED "true" 8 | # Role of anonymous user 9 | ENV GF_AUTH_ANONYMOUS_ORG_ROLE "Admin" -------------------------------------------------------------------------------- /release/standalone/docker-compose/grafana/grafana.ini: -------------------------------------------------------------------------------- 1 | [paths] 2 | provisioning = /etc/grafana/provisioning 3 | 4 | [server] 5 | enable_gzip = true 6 | 7 | [security] 8 | # If you want to embed grafana into an iframe for example 9 | allow_embedding = true 10 | 11 | [users] 12 | default_theme = dark -------------------------------------------------------------------------------- /release/standalone/docker-compose/mysql/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mysql:8.0.23 2 | 3 | LABEL maintainer="polaris" 4 | 5 | # Set Timezone 6 | ARG TZ=Asia/Shanghai 7 | ENV TZ ${TZ} 8 | RUN pwd \ 9 | && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \ 10 | && echo $TZ > /etc/timezone \ 11 | && chown -R mysql:root /var/lib/mysql/ \ 12 | && true 13 | 14 | EXPOSE 3306 15 | -------------------------------------------------------------------------------- /Code-of-Conduct.md: -------------------------------------------------------------------------------- 1 | # PolarisMesh Community Code of Conduct 2 | 3 | PolarisMesh follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md). 4 | 5 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the PolarisMesh Code 6 | of Conduct Committee via email: PolarisMesh_Community@qq.com -------------------------------------------------------------------------------- /release/standalone/port.properties: -------------------------------------------------------------------------------- 1 | polaris_eureka_port=8761 2 | polaris_open_api_port=8090 3 | polaris_service_grpc_port=8091 4 | polaris_config_grpc_port=8093 5 | polaris_prometheus_sd_port=9000 6 | polaris_xdsv3_port=15010 7 | polaris_console_port=8080 8 | polaris_limiter_http_port=8100 9 | polaris_limiter_grpc_port=8101 10 | prometheus_port=9090 11 | pushgateway_port=9091 12 | nacos_http_port=8848 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | polaris-server 2 | polaris-server-* 3 | polaris-server-release* 4 | polaris-server-release.tar.gz 5 | 6 | log/ 7 | /statis/ 8 | /discover-statis/ 9 | /discover-event/ 10 | 11 | .idea 12 | .DS_Store 13 | coverage* 14 | 15 | *.swp 16 | *.code-workspace 17 | 18 | __debug_bin 19 | 20 | .vscode 21 | *.bolt 22 | *.bolt.lock 23 | /vendor 24 | .codecc 25 | *.log 26 | 27 | style_tool/ 28 | goimports-reviser 29 | -------------------------------------------------------------------------------- /release/upgrade/circuitbreaker_rule_transform/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/polarismesh/polaris/release/upgrade/circuitbreaker_rule_transform 2 | 3 | go 1.19 4 | 5 | require ( 6 | github.com/golang/protobuf v1.5.2 // indirect 7 | github.com/polarismesh/specification v1.1.1 8 | ) 9 | 10 | require ( 11 | github.com/go-sql-driver/mysql v1.7.0 12 | github.com/google/uuid v1.3.0 13 | google.golang.org/protobuf v1.33.0 14 | ) 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **What is the feature you want to add?** 11 | 12 | **Why do you want to add this feature?** 13 | 14 | **How to implement this feature?** 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /test/suit/README.md: -------------------------------------------------------------------------------- 1 | # Polaris UnitTest Suit 接入 2 | 3 | ## 第三方存储插件接入单元测试体系 4 | 5 | - 实现 `TestDataClean` 接口 6 | - 在 `test/suit` 目录下写入一个 `go` 文件 7 | - 利用 `go _ import` 执行 `init` 方法的机制,调用 `testsuit.SetTestDataClean` 注入构建 `TestDataClean` 的 supplier 行数 8 | - 测试依赖第三方存储插件时的北极星启动配置文件 `polaris-server.yaml` 的路径信息,通过设置环境变量 `POLARIS_TEST_BOOTSTRAP_FILE` 9 | 10 | 具体参考 [polaris-contrib/polaris-store-postgresql](https://github.com/polaris-contrib/polaris-store-postgresql) 11 | -------------------------------------------------------------------------------- /test/tools/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/polarismesh/polaris/test/tools 2 | 3 | go 1.14 4 | 5 | require ( 6 | github.com/BurntSushi/toml v0.3.1 // indirect 7 | github.com/client9/misspell v0.3.4 8 | github.com/golang/protobuf v1.5.0 9 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 10 | golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135 11 | google.golang.org/protobuf v1.33.0 // indirect 12 | honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc 13 | ) 14 | -------------------------------------------------------------------------------- /release/cluster/helm/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *.orig 18 | *~ 19 | # Various IDEs 20 | .project 21 | .idea/ 22 | *.tmproj 23 | .vscode/ 24 | -------------------------------------------------------------------------------- /store/mock/README.md: -------------------------------------------------------------------------------- 1 | # 对Store的API的mock 2 | 3 | ## mock文件生成方法 4 | 5 | 在`./store`目录执行 6 | 7 | ``` 8 | mockgen -source=api.go -aux_files github.com/polarismesh/polaris/store=config_file_api.go,github.com/polarismesh/polaris/store=discover_api.go,github.com/polarismesh/polaris/store=auth_api.go,github.com/polarismesh/polaris/store=admin_api.go -destination=mock/api_mock.go -package=mock 9 | 10 | mockgen -source=mysql/admin.go -destination=mock/admin_mock.go -package=mock 11 | ``` -------------------------------------------------------------------------------- /release/upgrade/circuitbreaker_rule_transform/README.md: -------------------------------------------------------------------------------- 1 | ## 熔断规则迁移工具 2 | 3 | ### 说明 4 | 5 | 本工具主要用于将存量的熔断规则迁移到1.14.x及以上版本的熔断规则。 6 | 7 | ### 使用方式 8 | 9 | ***step1: 编译*** 10 | 11 | 将工具进行编译,再此目录下执行```go build```可完成迁移。 12 | 13 | ***step2: 升级数据库*** 14 | 15 | 执行数据库升级脚本,将数据库升级到1.14.x及以上版本的数据库,确保数据库中存在circuitbreaker_rule_v2的数据库表。 16 | 17 | ***step3: 执行迁移*** 18 | 19 | 执行迁移工具,并输入数据库的地址及用户名等信息,如下所示: 20 | 21 | ```shell 22 | ./circuitbreaker_rule_transform --db_addr=127.0.0.1:3306 --db_name=polaris_server --db_user=root --db_pwd=123456 23 | ``` -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior. 15 | 16 | **Expected behavior** 17 | A clear and concise description of what you expected to happen. 18 | 19 | **Environment** 20 | - Version: [e.g. v1.0.0] 21 | - OS: [e.g. CentOS8] 22 | 23 | **Additional context** 24 | Add any other context about the problem here. 25 | -------------------------------------------------------------------------------- /test/outlier/README.md: -------------------------------------------------------------------------------- 1 | # envoy outlier detection and health check 2 | 3 | frontend 服务定时向 backend 服务发送http 请求,默认会正常返回,可以给backend 某些pod 设置异常让其返回 http 500 模拟异常 4 | 5 | - 设置异常 6 | `curl http://localhost:8090/fail` 7 | 8 | - 异常恢复 9 | `curl http://localhost:8090/success` 10 | 11 | ## 安装 12 | 13 | - 构建镜像: 修改 build.sh repository 为可用的镜像仓库地址 ./build.sh 生成image 14 | 15 | - 创建namespace 并设置可注入 16 | ```bash 17 | kubectl create namespace polaris-test 18 | kubectl label namespace polaris-test polaris-injection=enabled 19 | ``` 20 | - 安装服务 21 | ```bash 22 | kubectl apply -f outlier.yaml 23 | ``` -------------------------------------------------------------------------------- /release/standalone/docker/prometheus/build_docker_prom.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# != 1 ]; then 4 | echo "e.g.: bash $0 v1.0" 5 | exit 1 6 | fi 7 | 8 | docker_tag=$1 9 | 10 | docker_repository="${DOCKER_REPOSITORY}" 11 | if [[ "${docker_repository}" == "" ]]; then 12 | docker_repository="polarismesh" 13 | fi 14 | 15 | echo "docker repository : ${docker_repository}/polaris-prometheus, tag : ${docker_tag}" 16 | 17 | docker buildx build --network=host -t ${docker_repository}/polaris-prometheus:${docker_tag} -t ${docker_repository}/polaris-prometheus:latest --platform linux/amd64,linux/arm64 --push ./ 18 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | **Please provide issue(s) of this PR:** 2 | Fixes # 3 | 4 | **To help us figure out who should review this PR, please put an X in all the areas that this PR affects.** 5 | 6 | - [ ] ApiServer 7 | - [ ] Auth 8 | - [ ] Configuration 9 | - [ ] Naming 10 | - [ ] HealthCheck 11 | - [ ] Metrics 12 | - [ ] Docs 13 | - [ ] Installation 14 | - [ ] Performance and Scalability 15 | - [ ] Test and Release 16 | 17 | **Please check any characteristics that apply to this pull request.** 18 | 19 | - [ ] Does not have any user-facing changes. This may include API changes, behavior changes, performance improvements, etc. 20 | -------------------------------------------------------------------------------- /test/benchmark/grpc/client/benchmark.md: -------------------------------------------------------------------------------- 1 | #### Discover Services 2 | 3 | ``` 4 | // goos: linux 5 | // goarch: amd64 6 | // pkg: github.com/polarismesh/polaris/test/benchmark/grpc 7 | // cpu: AMD EPYC 7K62 48-Core Processor 8 | 9 | 10 | // Benchmark_DiscoverServicesWithoutRevision-16 11 | // 763 1599653 ns/op 12 | // --- BENCH: Benchmark_DiscoverServicesWithoutRevision-16 13 | // discover_test.go:100: connection server success 14 | // discover_test.go:106: create discover client success 15 | // discover_test.go:100: connection server success 16 | // discover_test.go:106: create discover client success 17 | // discover_test.go:100: connection server success 18 | // discover_test.go:106: create discover client success 19 | ``` -------------------------------------------------------------------------------- /service/utils_test.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package service 19 | -------------------------------------------------------------------------------- /test/tools/tools_vet.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package tools 19 | -------------------------------------------------------------------------------- /cache/auth/policy_test.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package auth 19 | -------------------------------------------------------------------------------- /release/standalone/prometheus-help.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -lt 1 ]; then 4 | echo "$0 start port|stop" 5 | exit 0 6 | fi 7 | 8 | command=$1 9 | 10 | if [ ${command} == "start" ]; then 11 | prometheus_port=$2 12 | if [ "${prometheus_port}w" == "w" ]; then 13 | prometheus_port="9090" 14 | fi 15 | 16 | nohup ./polaris-prometheus --web.enable-lifecycle --web.enable-admin-api --web.listen-address=:${prometheus_port} >>prometheus.out 2>&1 & 17 | fi 18 | 19 | if [ ${command} == "stop" ]; then 20 | pid=$(ps -ef | grep polaris-prometheus | grep -v grep | awk '{print $2}') 21 | if [ "${pid}" != "" ]; then 22 | echo -e "start to kill polaris-prometheus process ${pid}" 23 | kill -9 ${pid} 24 | else 25 | echo "not found running polaris-prometheus" 26 | fi 27 | fi 28 | -------------------------------------------------------------------------------- /store/boltdb/circuitbreaker_test.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package boltdb 19 | -------------------------------------------------------------------------------- /test/outlier/backend/Dockerfile: -------------------------------------------------------------------------------- 1 | # Tencent is pleased to support the open source community by making Polaris available. 2 | # 3 | # Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 4 | # 5 | # Licensed under the BSD 3-Clause License (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://opensource.org/licenses/BSD-3-Clause 10 | # 11 | # Unless required by applicable law or agreed to in writing, software distributed 12 | # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | # CONDITIONS OF ANY KIND, either express or implied. See the License for the 14 | # specific language governing permissions and limitations under the License. 15 | 16 | FROM centos 17 | 18 | WORKDIR /data/app/ 19 | 20 | COPY ./main ./ 21 | 22 | CMD ["./main"] 23 | -------------------------------------------------------------------------------- /test/outlier/frontend/Dockerfile: -------------------------------------------------------------------------------- 1 | # Tencent is pleased to support the open source community by making Polaris available. 2 | # 3 | # Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 4 | # 5 | # Licensed under the BSD 3-Clause License (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://opensource.org/licenses/BSD-3-Clause 10 | # 11 | # Unless required by applicable law or agreed to in writing, software distributed 12 | # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | # CONDITIONS OF ANY KIND, either express or implied. See the License for the 14 | # specific language governing permissions and limitations under the License. 15 | 16 | FROM centos 17 | 18 | WORKDIR /data/app/ 19 | 20 | COPY ./main . 21 | 22 | CMD ["./main"] 23 | -------------------------------------------------------------------------------- /common/model/auth/context.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package auth 19 | 20 | type ( 21 | ContextKeyConditions struct{} 22 | ) 23 | -------------------------------------------------------------------------------- /release/tool/p.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem Tencent is pleased to support the open source community by making Polaris available. 4 | rem Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | rem Licensed under the BSD 3-Clause License (the "License"); 6 | rem you may not use this file except in compliance with the License. 7 | rem You may obtain a copy of the License at 8 | rem 9 | rem https://opensource.org/licenses/BSD-3-Clause 10 | rem 11 | rem Unless required by applicable law or agreed to in writing, software distributed 12 | rem under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | rem CONDITIONS OF ANY KIND, either express or implied. See the License for the 14 | rem specific language governing permissions and limitations under the License. 15 | 16 | set "SERVER_NAME=polaris-server.exe" 17 | tasklist | findstr "%SERVER_NAME%" -------------------------------------------------------------------------------- /test/integrate/strategy_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | // +build integration 3 | 4 | /** 5 | * Tencent is pleased to support the open source community by making Polaris available. 6 | * 7 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 8 | * 9 | * Licensed under the BSD 3-Clause License (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * https://opensource.org/licenses/BSD-3-Clause 14 | * 15 | * Unless required by applicable law or agreed to in writing, software distributed 16 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 17 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations under the License. 19 | */ 20 | 21 | package test 22 | -------------------------------------------------------------------------------- /release/standalone/docker-compose/prometheus/prometheus.yml: -------------------------------------------------------------------------------- 1 | # my global config 2 | global: 3 | scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. 4 | evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. 5 | # scrape_timeout is set to the global default (10s). 6 | 7 | 8 | # A scrape configuration containing exactly one endpoint to scrape: 9 | # Here it's Prometheus itself. 10 | scrape_configs: 11 | # The job name is added as a label `job=` to any timeseries scraped from this config. 12 | - job_name: "prometheus" 13 | static_configs: 14 | - targets: [ "localhost:9090" ] 15 | - job_name: "push-metrics" 16 | static_configs: 17 | - targets: [ "polaris-pushgateway:9091" ] 18 | - job_name: "polaris-server" 19 | http_sd_configs: 20 | - url: "http://polaris-server:8090/prometheus/v1/clients" 21 | -------------------------------------------------------------------------------- /plugin/ratelimit/token/limiter.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package token 19 | 20 | // limiter 限制器 21 | type limiter interface { 22 | allow(key string) bool 23 | } 24 | -------------------------------------------------------------------------------- /plugin/textexport.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package plugin 19 | 20 | import "sync" 21 | 22 | func TestCleanCryptoPlugin() { 23 | cryptoManagerOnce = sync.Once{} 24 | cryptoManager = nil 25 | } 26 | -------------------------------------------------------------------------------- /plugin/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package plugin 19 | 20 | import commonlog "github.com/polarismesh/polaris/common/log" 21 | 22 | var ( 23 | log = commonlog.GetScopeOrDefaultByName("plugin") 24 | ) 25 | -------------------------------------------------------------------------------- /plugin/ratelimit/token/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package token 19 | 20 | import commonLog "github.com/polarismesh/polaris/common/log" 21 | 22 | var log = commonLog.RegisterScope(PluginName, "", 0) 23 | -------------------------------------------------------------------------------- /apiserver/nacosserver/v1/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package v1 19 | 20 | import "github.com/polarismesh/polaris/apiserver/nacosserver/logger" 21 | 22 | var ( 23 | nacoslog = logger.GetNacosLog() 24 | ) 25 | -------------------------------------------------------------------------------- /apiserver/nacosserver/v2/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package v2 19 | 20 | import "github.com/polarismesh/polaris/apiserver/nacosserver/logger" 21 | 22 | var ( 23 | nacoslog = logger.GetNacosLog() 24 | ) 25 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package main 19 | 20 | import ( 21 | _ "go.uber.org/automaxprocs" 22 | 23 | "github.com/polarismesh/polaris/cmd" 24 | ) 25 | 26 | func main() { 27 | cmd.Execute() 28 | } 29 | -------------------------------------------------------------------------------- /test/integrate/group_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | // +build integration 3 | 4 | /** 5 | * Tencent is pleased to support the open source community by making Polaris available. 6 | * 7 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 8 | * 9 | * Licensed under the BSD 3-Clause License (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * https://opensource.org/licenses/BSD-3-Clause 14 | * 15 | * Unless required by applicable law or agreed to in writing, software distributed 16 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 17 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations under the License. 19 | */ 20 | 21 | package test 22 | 23 | import "testing" 24 | 25 | func TestGroup(t *testing.T) { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /test/integrate/user_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | // +build integration 3 | 4 | /** 5 | * Tencent is pleased to support the open source community by making Polaris available. 6 | * 7 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 8 | * 9 | * Licensed under the BSD 3-Clause License (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * https://opensource.org/licenses/BSD-3-Clause 14 | * 15 | * Unless required by applicable law or agreed to in writing, software distributed 16 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 17 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations under the License. 19 | */ 20 | 21 | package test 22 | 23 | import "testing" 24 | 25 | func TestUser(t *testing.T) { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /apiserver/nacosserver/core/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package core 19 | 20 | import "github.com/polarismesh/polaris/apiserver/nacosserver/logger" 21 | 22 | var ( 23 | nacoslog = logger.GetNacosLog() 24 | ) 25 | -------------------------------------------------------------------------------- /admin/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package admin 19 | 20 | import ( 21 | commonlog "github.com/polarismesh/polaris/common/log" 22 | ) 23 | 24 | var log = commonlog.GetScopeOrDefaultByName(commonlog.DefaultLoggerName) 25 | -------------------------------------------------------------------------------- /apiserver/nacosserver/v1/config/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package config 19 | 20 | import "github.com/polarismesh/polaris/apiserver/nacosserver/logger" 21 | 22 | var ( 23 | nacoslog = logger.GetNacosLog() 24 | ) 25 | -------------------------------------------------------------------------------- /apiserver/nacosserver/v2/config/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package config 19 | 20 | import "github.com/polarismesh/polaris/apiserver/nacosserver/logger" 21 | 22 | var ( 23 | nacoslog = logger.GetNacosLog() 24 | ) 25 | -------------------------------------------------------------------------------- /apiserver/nacosserver/v2/remote/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package remote 19 | 20 | import "github.com/polarismesh/polaris/apiserver/nacosserver/logger" 21 | 22 | var ( 23 | nacoslog = logger.GetNacosLog() 24 | ) 25 | -------------------------------------------------------------------------------- /cache/api/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package api 19 | 20 | import commonlog "github.com/polarismesh/polaris/common/log" 21 | 22 | var ( 23 | log = commonlog.GetScopeOrDefaultByName(commonlog.CacheLoggerName) 24 | ) 25 | -------------------------------------------------------------------------------- /cache/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package cache 19 | 20 | import commonlog "github.com/polarismesh/polaris/common/log" 21 | 22 | var ( 23 | log = commonlog.GetScopeOrDefaultByName(commonlog.CacheLoggerName) 24 | ) 25 | -------------------------------------------------------------------------------- /apiserver/nacosserver/v2/discover/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package discover 19 | 20 | import "github.com/polarismesh/polaris/apiserver/nacosserver/logger" 21 | 22 | var ( 23 | nacoslog = logger.GetNacosLog() 24 | ) 25 | -------------------------------------------------------------------------------- /cache/auth/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package auth 19 | 20 | import commonlog "github.com/polarismesh/polaris/common/log" 21 | 22 | var ( 23 | log = commonlog.GetScopeOrDefaultByName(commonlog.CacheLoggerName) 24 | ) 25 | -------------------------------------------------------------------------------- /cache/gray/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package gray 19 | 20 | import commonlog "github.com/polarismesh/polaris/common/log" 21 | 22 | var ( 23 | log = commonlog.GetScopeOrDefaultByName(commonlog.CacheLoggerName) 24 | ) 25 | -------------------------------------------------------------------------------- /auth/user/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package defaultuser 19 | 20 | import commonlog "github.com/polarismesh/polaris/common/log" 21 | 22 | var ( 23 | log = commonlog.GetScopeOrDefaultByName(commonlog.AuthLoggerName) 24 | ) 25 | -------------------------------------------------------------------------------- /service/batch/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package batch 19 | 20 | import ( 21 | commonlog "github.com/polarismesh/polaris/common/log" 22 | ) 23 | 24 | var log = commonlog.GetScopeOrDefaultByName(commonlog.NamingLoggerName) 25 | -------------------------------------------------------------------------------- /admin/interceptor/auth/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package auth 19 | 20 | import ( 21 | commonlog "github.com/polarismesh/polaris/common/log" 22 | ) 23 | 24 | var log = commonlog.GetScopeOrDefaultByName(commonlog.AuthLoggerName) 25 | -------------------------------------------------------------------------------- /release/cluster/kubernetes/01-polaris-console-config.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | data: 3 | polaris-console.yaml: |- 4 | logger: 5 | RotateOutputPath: log/polaris-console.log 6 | RotationMaxSize: 500 7 | RotationMaxAge: 30 8 | RotationMaxBackups: 100 9 | level: info 10 | webServer: 11 | mode: "release" 12 | listenIP: "0.0.0.0" 13 | listenPort: 8080 14 | jwt: 15 | secretKey: "polarismesh@2021" 16 | expired: 1800 17 | namingV1URL: "/naming/v1" 18 | namingV2URL: "/naming/v2" 19 | authURL: "/core/v1" 20 | requestURL: "/naming/v1" 21 | configURL: "/config/v1" 22 | monitorURL: "/api/v1" 23 | webPath: "web/dist/" 24 | polarisServer: 25 | address: "127.0.0.1:8090" 26 | polarisToken: "polaris@12345678" 27 | monitorServer: 28 | address: "polaris-prometheus:9090" 29 | kind: ConfigMap 30 | metadata: 31 | name: polaris-console-config 32 | namespace: polaris-system 33 | -------------------------------------------------------------------------------- /apiserver/l5pbserver/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package l5pbserver 19 | 20 | import ( 21 | commonlog "github.com/polarismesh/polaris/common/log" 22 | ) 23 | 24 | var log = commonlog.GetScopeOrDefaultByName(commonlog.NamingLoggerName) 25 | -------------------------------------------------------------------------------- /apiserver/xdsserverv3/cache/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package cache 19 | 20 | import ( 21 | commonlog "github.com/polarismesh/polaris/common/log" 22 | ) 23 | 24 | var log = commonlog.GetScopeOrDefaultByName(commonlog.XDSLoggerName) 25 | -------------------------------------------------------------------------------- /apiserver/xdsserverv3/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package xdsserverv3 19 | 20 | import ( 21 | commonlog "github.com/polarismesh/polaris/common/log" 22 | ) 23 | 24 | var log = commonlog.GetScopeOrDefaultByName(commonlog.XDSLoggerName) 25 | -------------------------------------------------------------------------------- /auth/policy/inteceptor/auth/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package auth 19 | 20 | import commonlog "github.com/polarismesh/polaris/common/log" 21 | 22 | var ( 23 | log = commonlog.GetScopeOrDefaultByName(commonlog.AuthLoggerName) 24 | ) 25 | -------------------------------------------------------------------------------- /auth/user/inteceptor/auth/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package auth 19 | 20 | import commonlog "github.com/polarismesh/polaris/common/log" 21 | 22 | var ( 23 | log = commonlog.GetScopeOrDefaultByName(commonlog.AuthLoggerName) 24 | ) 25 | -------------------------------------------------------------------------------- /apiserver/xdsserverv3/resource/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package resource 19 | 20 | import ( 21 | commonlog "github.com/polarismesh/polaris/common/log" 22 | ) 23 | 24 | var log = commonlog.GetScopeOrDefaultByName(commonlog.XDSLoggerName) 25 | -------------------------------------------------------------------------------- /service/healthcheck/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package healthcheck 19 | 20 | import ( 21 | commonlog "github.com/polarismesh/polaris/common/log" 22 | ) 23 | 24 | var log = commonlog.GetScopeOrDefaultByName(commonlog.HealthcheckLoggerName) 25 | -------------------------------------------------------------------------------- /apiserver/nacosserver/model/event.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package model 19 | 20 | const ( 21 | NacosServicesChangeEventTopic = "NacosServicesChangeEvent" 22 | ) 23 | 24 | type NacosServicesChangeEvent struct { 25 | Services []*ServiceMetadata 26 | } 27 | -------------------------------------------------------------------------------- /namespace/interceptor/auth/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package auth 19 | 20 | import ( 21 | commonlog "github.com/polarismesh/polaris/common/log" 22 | ) 23 | 24 | var ( 25 | authLog = commonlog.GetScopeOrDefaultByName(commonlog.AuthLoggerName) 26 | ) 27 | -------------------------------------------------------------------------------- /apiserver/httpserver/default.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package httpserver 19 | 20 | import ( 21 | "github.com/polarismesh/polaris/apiserver" 22 | ) 23 | 24 | // init 自注册到API服务器插槽 25 | func init() { 26 | _ = apiserver.Register("api-http", &HTTPServer{}) 27 | } 28 | -------------------------------------------------------------------------------- /apiserver/l5pbserver/default.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package l5pbserver 19 | 20 | import ( 21 | "github.com/polarismesh/polaris/apiserver" 22 | ) 23 | 24 | // init 自注册到API服务器插槽 25 | func init() { 26 | _ = apiserver.Register("service-l5", &L5pbserver{}) 27 | } 28 | -------------------------------------------------------------------------------- /apiserver/xdsserverv3/default.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package xdsserverv3 19 | 20 | import ( 21 | "github.com/polarismesh/polaris/apiserver" 22 | ) 23 | 24 | // init 自注册到API服务器插槽 25 | func init() { 26 | _ = apiserver.Register("xds-v3", &XDSServer{}) 27 | } 28 | -------------------------------------------------------------------------------- /cache/auth/default.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package auth 19 | 20 | import ( 21 | types "github.com/polarismesh/polaris/cache/api" 22 | ) 23 | 24 | var ( 25 | _ types.UserCache = (*userCache)(nil) 26 | _ types.StrategyCache = (*policyCache)(nil) 27 | ) 28 | -------------------------------------------------------------------------------- /release/standalone/windows/run.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem Tencent is pleased to support the open source community by making Polaris available. 4 | rem Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | rem Licensed under the BSD 3-Clause License (the "License"); 6 | rem you may not use this file except in compliance with the License. 7 | rem You may obtain a copy of the License at 8 | rem 9 | rem https://opensource.org/licenses/BSD-3-Clause 10 | rem 11 | rem Unless required by applicable law or agreed to in writing, software distributed 12 | rem under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | rem CONDITIONS OF ANY KIND, either express or implied. See the License for the 14 | rem specific language governing permissions and limitations under the License. 15 | 16 | setlocal 17 | set "CURRENT_DIR=%cd%" 18 | rem powershell -c "Set-ExecutionPolicy RemoteSigned" 19 | echo allowed to use powershell 20 | powershell -File %CURRENT_DIR%\run-windows.ps1 21 | endlocal 22 | 23 | pause -------------------------------------------------------------------------------- /common/conn/limit/stats.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package connlimit 19 | 20 | import "time" 21 | 22 | // HostConnStat 连接的统计信息 23 | type HostConnStat struct { 24 | Host string 25 | Amount int32 26 | LastAccess time.Time 27 | Actives []string 28 | } 29 | -------------------------------------------------------------------------------- /apiserver/grpcserver/config/default.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package config 19 | 20 | import ( 21 | "github.com/polarismesh/polaris/apiserver" 22 | ) 23 | 24 | // init 自注册到API服务器插槽 25 | func init() { 26 | _ = apiserver.Register("config-grpc", &ConfigGRPCServer{}) 27 | } 28 | -------------------------------------------------------------------------------- /apiserver/grpcserver/discover/default.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package discover 19 | 20 | import ( 21 | "github.com/polarismesh/polaris/apiserver" 22 | ) 23 | 24 | // init 自注册到API服务器插槽 25 | func init() { 26 | _ = apiserver.Register("service-grpc", &GRPCServer{}) 27 | } 28 | -------------------------------------------------------------------------------- /release/standalone/windows/install.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem Tencent is pleased to support the open source community by making Polaris available. 4 | rem Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | rem Licensed under the BSD 3-Clause License (the "License"); 6 | rem you may not use this file except in compliance with the License. 7 | rem You may obtain a copy of the License at 8 | rem 9 | rem https://opensource.org/licenses/BSD-3-Clause 10 | rem 11 | rem Unless required by applicable law or agreed to in writing, software distributed 12 | rem under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | rem CONDITIONS OF ANY KIND, either express or implied. See the License for the 14 | rem specific language governing permissions and limitations under the License. 15 | 16 | setlocal 17 | set "CURRENT_DIR=%cd%" 18 | rem powershell -c "Set-ExecutionPolicy RemoteSigned" 19 | echo allowed to use powershell 20 | powershell -File %CURRENT_DIR%\install-windows.ps1 21 | endlocal 22 | 23 | pause -------------------------------------------------------------------------------- /release/standalone/windows/stop.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem Tencent is pleased to support the open source community by making Polaris available. 4 | rem Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | rem Licensed under the BSD 3-Clause License (the "License"); 6 | rem you may not use this file except in compliance with the License. 7 | rem You may obtain a copy of the License at 8 | rem 9 | rem https://opensource.org/licenses/BSD-3-Clause 10 | rem 11 | rem Unless required by applicable law or agreed to in writing, software distributed 12 | rem under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | rem CONDITIONS OF ANY KIND, either express or implied. See the License for the 14 | rem specific language governing permissions and limitations under the License. 15 | 16 | setlocal 17 | set "CURRENT_DIR=%cd%" 18 | rem powershell -c "Set-ExecutionPolicy RemoteSigned" 19 | echo allowed to use powershell 20 | powershell -File %CURRENT_DIR%\stop-windows.ps1 21 | endlocal 22 | 23 | pause 24 | -------------------------------------------------------------------------------- /cache/config/default.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package config 19 | 20 | import ( 21 | types "github.com/polarismesh/polaris/cache/api" 22 | ) 23 | 24 | var ( 25 | _ types.ConfigFileCache = (*fileCache)(nil) 26 | _ types.ConfigGroupCache = (*configGroupCache)(nil) 27 | ) 28 | -------------------------------------------------------------------------------- /release/standalone/windows/uninstall.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem Tencent is pleased to support the open source community by making Polaris available. 4 | rem Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | rem Licensed under the BSD 3-Clause License (the "License"); 6 | rem you may not use this file except in compliance with the License. 7 | rem You may obtain a copy of the License at 8 | rem 9 | rem https://opensource.org/licenses/BSD-3-Clause 10 | rem 11 | rem Unless required by applicable law or agreed to in writing, software distributed 12 | rem under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | rem CONDITIONS OF ANY KIND, either express or implied. See the License for the 14 | rem specific language governing permissions and limitations under the License. 15 | 16 | setlocal* 17 | set "CURRENT_DIR=%cd%" 18 | rem powershell -c "Set-ExecutionPolicy RemoteSigned" 19 | echo allowed to use powershell 20 | powershell -File %CURRENT_DIR%\uninstall-windows.ps1 21 | endlocal 22 | 23 | pause -------------------------------------------------------------------------------- /release/standalone/docker-compose/grafana/provisioning/dashboards/dashboard.yml: -------------------------------------------------------------------------------- 1 | # config file version 2 | apiVersion: 1 3 | 4 | providers: 5 | # an unique provider name 6 | - name: Polaris Golang Runtime 7 | # org id. will default to orgId 1 if not specified 8 | org_id: 1 9 | # name of the dashboard folder. Required 10 | folder: '' 11 | # provider type. Required 12 | type: 'file' 13 | # disable dashboard deletion 14 | disableDeletion: false 15 | # enable dashboard editing 16 | editable: true 17 | # how often Grafana will scan for changed dashboards 18 | updateIntervalSeconds: 5 19 | # allow updating provisioned dashboards from the UI 20 | allowUiUpdates: true 21 | options: 22 | # path to dashboard files on disk. Required 23 | path: /etc/grafana/dashboards 24 | # use folder names from filesystem to create folders in Grafana 25 | foldersFromFilesStructure: true -------------------------------------------------------------------------------- /test/integrate/http/user.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package http 19 | 20 | import ( 21 | apisecurity "github.com/polarismesh/specification/source/go/api/v1/security" 22 | ) 23 | 24 | func Login(username, password string) (*apisecurity.LoginResponse, error) { 25 | return nil, nil 26 | } 27 | -------------------------------------------------------------------------------- /apiserver/eurekaserver/default.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package eurekaserver 19 | 20 | import ( 21 | "github.com/polarismesh/polaris/apiserver" 22 | ) 23 | 24 | /** 25 | * @brief 自注册到API服务器插槽 26 | */ 27 | func init() { 28 | _ = apiserver.Register("service-eureka", &EurekaServer{}) 29 | } 30 | -------------------------------------------------------------------------------- /plugin/statis/logger/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package logger 19 | 20 | import commonlog "github.com/polarismesh/polaris/common/log" 21 | 22 | var ( 23 | log = commonlog.RegisterScope(PluginName, "", 0) 24 | discoverlog = commonlog.RegisterScope("discoverstat", "", 0) 25 | ) 26 | -------------------------------------------------------------------------------- /admin/job/config.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package job 19 | 20 | // JobcConfig maintain job configuration 21 | type JobConfig struct { 22 | Name string `yaml:"name"` 23 | Enable bool `yaml:"enable"` 24 | Option map[string]interface{} `yaml:"option"` 25 | } 26 | -------------------------------------------------------------------------------- /common/hash/fnv32.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package hash 19 | 20 | func Fnv32(key string) int { 21 | hash := uint32(2166136261) 22 | const prime32 = uint32(16777619) 23 | for i := 0; i < len(key); i++ { 24 | hash *= prime32 25 | hash ^= uint32(key[i]) 26 | } 27 | return int(hash) 28 | } 29 | -------------------------------------------------------------------------------- /plugin/ratelimit/token/register.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package token 19 | 20 | import "github.com/polarismesh/polaris/plugin" 21 | 22 | const ( 23 | PluginName = "token-bucket" 24 | ) 25 | 26 | // init 插件入口注册函数 27 | func init() { 28 | plugin.RegisterPlugin(PluginName, &tokenBucket{}) 29 | } 30 | -------------------------------------------------------------------------------- /config/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package config 19 | 20 | import commonLog "github.com/polarismesh/polaris/common/log" 21 | 22 | var ( 23 | log = commonLog.GetScopeOrDefaultByName(commonLog.ConfigLoggerName) 24 | authLog = commonLog.GetScopeOrDefaultByName(commonLog.AuthLoggerName) 25 | ) 26 | -------------------------------------------------------------------------------- /auth/policy/action_map.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package policy 19 | 20 | var actionsMap map[string]string 21 | 22 | func InitActionMapping() { 23 | // TODO 24 | } 25 | 26 | func GetRealAction(s string) string { 27 | val, ok := actionsMap[s] 28 | if !ok { 29 | return s 30 | } 31 | return val 32 | } 33 | -------------------------------------------------------------------------------- /common/model/http.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package model 19 | 20 | import "net/http" 21 | 22 | type DebugHandlerGroup struct { 23 | Name string 24 | Handlers []DebugHandler 25 | } 26 | 27 | type DebugHandler struct { 28 | Desc string 29 | Path string 30 | Handler http.HandlerFunc 31 | } 32 | -------------------------------------------------------------------------------- /plugin/sync.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package plugin 19 | 20 | import "github.com/polarismesh/polaris/common/model" 21 | 22 | // Syncer . 23 | type Syncer interface { 24 | Plugin 25 | // Run 26 | Run() error 27 | // DebugHandlers return debug handlers 28 | DebugHandlers() []model.DebugHandler 29 | } 30 | -------------------------------------------------------------------------------- /cache/config/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package config 19 | 20 | import commonlog "github.com/polarismesh/polaris/common/log" 21 | 22 | var ( 23 | log = commonlog.GetScopeOrDefaultByName(commonlog.CacheLoggerName) 24 | configLog = commonlog.GetScopeOrDefaultByName(commonlog.ConfigLoggerName) 25 | ) 26 | -------------------------------------------------------------------------------- /cache/service/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package service 19 | 20 | import commonlog "github.com/polarismesh/polaris/common/log" 21 | 22 | var ( 23 | log = commonlog.GetScopeOrDefaultByName(commonlog.CacheLoggerName) 24 | naminglog = commonlog.GetScopeOrDefaultByName(commonlog.NamingLoggerName) 25 | ) 26 | -------------------------------------------------------------------------------- /auth/policy/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package policy 19 | 20 | import commonlog "github.com/polarismesh/polaris/common/log" 21 | 22 | var ( 23 | log = commonlog.GetScopeOrDefaultByName(commonlog.AuthLoggerName) 24 | sysOplog = commonlog.GetScopeOrDefaultByName(commonlog.SystemOperationLoggerName) 25 | ) 26 | -------------------------------------------------------------------------------- /service/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package service 19 | 20 | import ( 21 | commonlog "github.com/polarismesh/polaris/common/log" 22 | ) 23 | 24 | var ( 25 | log = commonlog.GetScopeOrDefaultByName(commonlog.NamingLoggerName) 26 | authLog = commonlog.GetScopeOrDefaultByName(commonlog.AuthLoggerName) 27 | ) 28 | -------------------------------------------------------------------------------- /common/model/context_key.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package model 19 | 20 | type ( 21 | // ContextKeyAutoCreateNamespace . 22 | ContextKeyAutoCreateNamespace struct{} 23 | // ContextKeyAutoCreateService . 24 | ContextKeyAutoCreateService struct{} 25 | // ContextKeyCompatible . 26 | ContextKeyCompatible struct{} 27 | ) 28 | -------------------------------------------------------------------------------- /config/interceptor/auth/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package config_auth 19 | 20 | import commonLog "github.com/polarismesh/polaris/common/log" 21 | 22 | var ( 23 | log = commonLog.GetScopeOrDefaultByName(commonLog.ConfigLoggerName) 24 | authLog = commonLog.GetScopeOrDefaultByName(commonLog.AuthLoggerName) 25 | ) 26 | -------------------------------------------------------------------------------- /namespace/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package namespace 19 | 20 | import ( 21 | commonlog "github.com/polarismesh/polaris/common/log" 22 | ) 23 | 24 | var ( 25 | log = commonlog.GetScopeOrDefaultByName(commonlog.DefaultLoggerName) 26 | authLog = commonlog.GetScopeOrDefaultByName(commonlog.AuthLoggerName) 27 | ) 28 | -------------------------------------------------------------------------------- /store/boltdb/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package boltdb 19 | 20 | import ( 21 | commonlog "github.com/polarismesh/polaris/common/log" 22 | ) 23 | 24 | var ( 25 | log = commonlog.GetScopeOrDefaultByName(commonlog.StoreLoggerName) 26 | authLog = commonlog.GetScopeOrDefaultByName(commonlog.AuthLoggerName) 27 | ) 28 | -------------------------------------------------------------------------------- /store/boltdb/tool.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package boltdb 19 | 20 | import "time" 21 | 22 | // toolStore 实现了ToolStoreStore 23 | type toolStore struct { 24 | } 25 | 26 | // GetUnixSecond 获取当前时间,单位秒 27 | func (t *toolStore) GetUnixSecond(maxWait time.Duration) (int64, error) { 28 | return time.Now().Unix(), nil 29 | } 30 | -------------------------------------------------------------------------------- /store/mysql/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package sqldb 19 | 20 | import ( 21 | commonlog "github.com/polarismesh/polaris/common/log" 22 | ) 23 | 24 | var ( 25 | log = commonlog.GetScopeOrDefaultByName(commonlog.StoreLoggerName) 26 | cacheLog = commonlog.GetScopeOrDefaultByName(commonlog.CacheLoggerName) 27 | ) 28 | -------------------------------------------------------------------------------- /apiserver/eurekaserver/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package eurekaserver 19 | 20 | import ( 21 | commonlog "github.com/polarismesh/polaris/common/log" 22 | ) 23 | 24 | var ( 25 | accesslog = commonlog.GetScopeOrDefaultByName(commonlog.APIServerLoggerName) 26 | eurekalog = commonlog.GetScopeOrDefaultByName("eureka") 27 | ) 28 | -------------------------------------------------------------------------------- /config/interceptor/paramcheck/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package paramcheck 19 | 20 | import commonLog "github.com/polarismesh/polaris/common/log" 21 | 22 | var ( 23 | log = commonLog.GetScopeOrDefaultByName(commonLog.ConfigLoggerName) 24 | authLog = commonLog.GetScopeOrDefaultByName(commonLog.AuthLoggerName) 25 | ) 26 | -------------------------------------------------------------------------------- /apiserver/nacosserver/default.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package nacosserver 19 | 20 | import ( 21 | "github.com/polarismesh/polaris/apiserver" 22 | _ "github.com/polarismesh/polaris/apiserver/nacosserver/v2" 23 | ) 24 | 25 | // init 自注册到API服务器插槽 26 | func init() { 27 | _ = apiserver.Register(ProtooclName, &NacosServer{}) 28 | } 29 | -------------------------------------------------------------------------------- /release/cluster/helm/templates/config-polaris-console.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: polaris-console-config 5 | namespace: {{ .Values.installation.namespace }} 6 | data: 7 | polaris-console.yaml: |- 8 | logger: 9 | RotateOutputPath: log/polaris-console.log 10 | RotationMaxSize: 500 11 | RotationMaxAge: 30 12 | RotationMaxBackups: 100 13 | level: info 14 | webServer: 15 | mode: "release" 16 | listenIP: "0.0.0.0" 17 | listenPort: {{ .Values.service.webPort }} 18 | jwt: 19 | secretKey: "polarismesh@2021" 20 | expired: 1800 21 | namingV1URL: "/naming/v1" 22 | namingV2URL: "/naming/v2" 23 | authURL: "/core/v1" 24 | configURL: "/config/v1" 25 | monitorURL: "/api/v1" 26 | webPath: "web/dist/" 27 | polarisServer: 28 | address: "127.0.0.1:{{ .Values.service.httpPort }}" 29 | polarisToken: "nu/0WRA4EqSR1FagrjRj0fZwPXuGlMpX+zCuWu4uMqy8xr1vRjisSbA25aAC3mtU8MeeRsKhQiDAynUR09I=" 30 | monitorServer: 31 | address: "polaris-prometheus:9090" 32 | -------------------------------------------------------------------------------- /service/interceptor/auth/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package service_auth 19 | 20 | import ( 21 | commonlog "github.com/polarismesh/polaris/common/log" 22 | ) 23 | 24 | var ( 25 | log = commonlog.GetScopeOrDefaultByName(commonlog.NamingLoggerName) 26 | authLog = commonlog.GetScopeOrDefaultByName(commonlog.AuthLoggerName) 27 | ) 28 | -------------------------------------------------------------------------------- /plugin/healthchecker/leader/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package leader 19 | 20 | import ( 21 | commonlog "github.com/polarismesh/polaris/common/log" 22 | ) 23 | 24 | var ( 25 | log = commonlog.GetScopeOrDefaultByName(commonlog.HealthcheckLoggerName) 26 | plog = commonlog.GetScopeByName(PluginName, commonlog.HealthcheckLoggerName) 27 | ) 28 | -------------------------------------------------------------------------------- /release/standalone/docker-compose/README.md: -------------------------------------------------------------------------------- 1 | ## Docker-Compose 单机版本 2 | 3 | ### 服务组成 4 | 5 | - polaris-server 北极星核心服务 6 | - polaris-console 北极星控制台 7 | - mysql 替换默认的boltdb存储 8 | - polaris-prometheus 9 | - polaris-pushgateway 10 | - grafana 11 | 12 | ### 创建存储卷 13 | 14 | 创建mysql、redis 存储卷,方便数据持久化 15 | 16 | ```shell 17 | docker volume create --name=vlm_data_mysql 18 | ``` 19 | 20 | ### 启动服务 21 | 22 | ```shell 23 | cd polaris/deploy/standalone/docker-compose 24 | docker-compose up -d 25 | ``` 26 | 27 | 第一次执行,mysql 启动会导入`polaris-server`的数据库SQL,需要一定启动时间,如果发现服务启动失败,简单起见,通过`restart`实现自动 28 | 重启`polaris-server`。 29 | 30 | ```shell 31 | cd polaris/deploy/standalone/docker-compose 32 | docker-compose up -d polaris-server 33 | ``` 34 | 35 | ### 停止服务 36 | 37 | ```shell 38 | cd polaris/deploy/standalone/docker-compose 39 | docker-compose stop 40 | ``` 41 | 42 | ### 清理服务 43 | 44 | ```shell 45 | cd polaris/deploy/standalone/docker-compose 46 | docker-compose down 47 | ``` 48 | 49 | ### 释放存储卷 50 | 51 | ```shell 52 | docker volume rm vlm_data_mysql 53 | ``` 54 | 55 | ### 访问 56 | 57 | 浏览器访问`http://localhost:8080/#`进入管控台 -------------------------------------------------------------------------------- /store/mysql/common_test.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package sqldb 19 | 20 | import ( 21 | "testing" 22 | 23 | "github.com/stretchr/testify/assert" 24 | ) 25 | 26 | func TestToUnderscoreName(t *testing.T) { 27 | assert.Equal(t, "dst_service", toUnderscoreName("dstService")) 28 | assert.Equal(t, "src_service", toUnderscoreName("srcService")) 29 | } 30 | -------------------------------------------------------------------------------- /test/tools/tools.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | //go:build tools 19 | // +build tools 20 | 21 | package tools 22 | 23 | import ( 24 | _ "github.com/client9/misspell/cmd/misspell" 25 | _ "github.com/golang/protobuf/protoc-gen-go" 26 | _ "golang.org/x/lint/golint" 27 | _ "golang.org/x/tools/cmd/goimports" 28 | _ "honnef.co/go/tools/cmd/staticcheck" 29 | ) 30 | -------------------------------------------------------------------------------- /store/sql.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package store 19 | 20 | // InstanceArgs 用于通过服务实例查询服务的参数 21 | type InstanceArgs struct { 22 | Hosts []string 23 | Ports []uint32 24 | Meta map[string]string 25 | } 26 | 27 | type InstanceMetadataRequest struct { 28 | InstanceID string 29 | Revision string 30 | Keys []string 31 | Metadata map[string]string 32 | } 33 | -------------------------------------------------------------------------------- /release/tool/stop.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem Tencent is pleased to support the open source community by making Polaris available. 4 | rem Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | rem Licensed under the BSD 3-Clause License (the "License"); 6 | rem you may not use this file except in compliance with the License. 7 | rem You may obtain a copy of the License at 8 | rem 9 | rem https://opensource.org/licenses/BSD-3-Clause 10 | rem 11 | rem Unless required by applicable law or agreed to in writing, software distributed 12 | rem under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | rem CONDITIONS OF ANY KIND, either express or implied. See the License for the 14 | rem specific language governing permissions and limitations under the License. 15 | 16 | setlocal 17 | 18 | set "SERVER_NAME=polaris-server.exe" 19 | 20 | for /F "TOKENS=1,2,*" %%a in ('tasklist ^| findstr "%SERVER_NAME%"') do ( 21 | echo "process is %%b" 22 | if not "%%b" equ "" ( 23 | echo "start to kill %%b" 24 | taskkill /PID %%b /T /F 25 | ) 26 | ) 27 | 28 | endlocal 29 | 30 | -------------------------------------------------------------------------------- /service/batch/client_future_test.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package batch 19 | 20 | import ( 21 | "testing" 22 | 23 | "github.com/stretchr/testify/assert" 24 | 25 | "github.com/polarismesh/polaris/common/model" 26 | ) 27 | 28 | func TestClientFuture_SetClient(t *testing.T) { 29 | f := &ClientFuture{} 30 | 31 | f.SetClient(&model.Client{}) 32 | assert.NotNil(t, f.Client()) 33 | } 34 | -------------------------------------------------------------------------------- /test/outlier/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Tencent is pleased to support the open source community by making Polaris available. 3 | # 4 | # Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | # 6 | # Licensed under the BSD 3-Clause License (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://opensource.org/licenses/BSD-3-Clause 11 | # 12 | # Unless required by applicable law or agreed to in writing, software distributed 13 | # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | # CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations under the License. 16 | 17 | repository="repository" 18 | cd frontend 19 | go build main.go 20 | docker build -t $repository/outlier_frontend . 21 | 22 | cd ../backend 23 | go build main.go 24 | docker build -t $repository/outlier_backend . 25 | 26 | docker push $repository/outlier_frontend 27 | docker push $repository/outlier_backend 28 | 29 | cd ../ 30 | sed -i "s/repository/$repository/g" ./outlier.yaml 31 | -------------------------------------------------------------------------------- /apiserver/httpserver/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package httpserver 19 | 20 | import ( 21 | commonlog "github.com/polarismesh/polaris/common/log" 22 | ) 23 | 24 | var ( 25 | log = commonlog.GetScopeOrDefaultByName(commonlog.APIServerLoggerName) 26 | namingLog = commonlog.GetScopeOrDefaultByName(commonlog.NamingLoggerName) 27 | configLog = commonlog.GetScopeOrDefaultByName(commonlog.ConfigLoggerName) 28 | ) 29 | -------------------------------------------------------------------------------- /release/tool/stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Tencent is pleased to support the open source community by making Polaris available. 3 | # 4 | # Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | # 6 | # Licensed under the BSD 3-Clause License (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://opensource.org/licenses/BSD-3-Clause 11 | # 12 | # Unless required by applicable law or agreed to in writing, software distributed 13 | # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | # CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations under the License. 16 | 17 | curpath=$(pwd) 18 | 19 | if [ "${0:0:1}" == "/" ]; then 20 | dir=$(dirname "$0") 21 | else 22 | dir=$(pwd)/$(dirname "$0") 23 | fi 24 | 25 | cd $dir/.. 26 | workdir=$(pwd) 27 | 28 | #------------------------------------------------------ 29 | source tool/include 30 | 31 | del_cron 32 | stop 33 | 34 | #------------------------------------------------------ 35 | 36 | cd $curpath 37 | -------------------------------------------------------------------------------- /apiserver/httpserver/config/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package config 19 | 20 | import ( 21 | commonlog "github.com/polarismesh/polaris/common/log" 22 | ) 23 | 24 | var ( 25 | log = commonlog.GetScopeOrDefaultByName(commonlog.APIServerLoggerName) 26 | namingLog = commonlog.GetScopeOrDefaultByName(commonlog.NamingLoggerName) 27 | configLog = commonlog.GetScopeOrDefaultByName(commonlog.ConfigLoggerName) 28 | ) 29 | -------------------------------------------------------------------------------- /apiserver/httpserver/discover/v1/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package v1 19 | 20 | import ( 21 | commonlog "github.com/polarismesh/polaris/common/log" 22 | ) 23 | 24 | var ( 25 | log = commonlog.GetScopeOrDefaultByName(commonlog.APIServerLoggerName) 26 | namingLog = commonlog.GetScopeOrDefaultByName(commonlog.NamingLoggerName) 27 | configLog = commonlog.GetScopeOrDefaultByName(commonlog.ConfigLoggerName) 28 | ) 29 | -------------------------------------------------------------------------------- /apiserver/httpserver/discover/v2/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package v2 19 | 20 | import ( 21 | commonlog "github.com/polarismesh/polaris/common/log" 22 | ) 23 | 24 | var ( 25 | log = commonlog.GetScopeOrDefaultByName(commonlog.APIServerLoggerName) 26 | namingLog = commonlog.GetScopeOrDefaultByName(commonlog.NamingLoggerName) 27 | configLog = commonlog.GetScopeOrDefaultByName(commonlog.ConfigLoggerName) 28 | ) 29 | -------------------------------------------------------------------------------- /release/tool/p.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Tencent is pleased to support the open source community by making Polaris available. 3 | # 4 | # Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | # 6 | # Licensed under the BSD 3-Clause License (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://opensource.org/licenses/BSD-3-Clause 11 | # 12 | # Unless required by applicable law or agreed to in writing, software distributed 13 | # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | # CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations under the License. 16 | 17 | 18 | curpath=$(pwd) 19 | 20 | if [ "${0:0:1}" == "/" ]; then 21 | dir=$(dirname "$0") 22 | else 23 | dir=$(pwd)/$(dirname "$0") 24 | fi 25 | 26 | cd $dir/.. 27 | workdir=$(pwd) 28 | 29 | #------------------------------------------------------ 30 | source tool/include 31 | 32 | ps -ef | grep -w "$cmdline" | grep -v "grep" 33 | 34 | #------------------------------------------------------ 35 | 36 | cd $curpath 37 | -------------------------------------------------------------------------------- /release/standalone/docker/prometheus/prometheus.yml: -------------------------------------------------------------------------------- 1 | # my global config 2 | global: 3 | scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. 4 | evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. 5 | # scrape_timeout is set to the global default (10s). 6 | 7 | # Alertmanager configuration 8 | alerting: 9 | alertmanagers: 10 | - static_configs: 11 | - targets: 12 | # - alertmanager:9093 13 | 14 | # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. 15 | rule_files: 16 | # - "first_rules.yml" 17 | # - "second_rules.yml" 18 | 19 | # A scrape configuration containing exactly one endpoint to scrape: 20 | # Here it's Prometheus itself. 21 | scrape_configs: 22 | # The job name is added as a label `job=` to any timeseries scraped from this config. 23 | - job_name: "prometheus" 24 | 25 | # metrics_path defaults to '/metrics' 26 | # scheme defaults to 'http'. 27 | 28 | static_configs: 29 | - targets: ["localhost:9090"] 30 | 31 | http_sd_configs: 32 | - url: http://polaris:8090/prometheus/v1/clients 33 | 34 | honor_labels: true 35 | -------------------------------------------------------------------------------- /test/data/testdata.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package testdata 19 | 20 | import ( 21 | "path/filepath" 22 | "runtime" 23 | ) 24 | 25 | var basepath string 26 | 27 | func init() { 28 | _, currentFile, _, _ := runtime.Caller(0) 29 | basepath = filepath.Dir(currentFile) 30 | } 31 | 32 | // Path gets the absolute path. 33 | func Path(rel string) string { 34 | if filepath.IsAbs(rel) { 35 | return rel 36 | } 37 | return filepath.Join(basepath, rel) 38 | } 39 | -------------------------------------------------------------------------------- /cache/client/client_metrics.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package cache_client 19 | 20 | import ( 21 | "github.com/polarismesh/polaris/common/metrics" 22 | "github.com/polarismesh/polaris/plugin" 23 | ) 24 | 25 | func (c *clientCache) reportMetricsInfo() { 26 | c.lock.RLock() 27 | defer c.lock.RUnlock() 28 | plugin.GetStatis().ReportDiscoveryMetrics(metrics.DiscoveryMetric{ 29 | Type: metrics.ClientMetrics, 30 | Total: int64(len(c.clients)), 31 | }) 32 | } 33 | -------------------------------------------------------------------------------- /store/mysql/scripts/delta/v1_14_0-v1_17_0.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | -- 18 | -- Database: `polaris_server` 19 | -- 20 | USE `polaris_server`; 21 | 22 | ALTER TABLE instance_metadata DROP FOREIGN KEY `instance_metadata_ibfk_1`; 23 | ALTER TABLE service_metadata DROP FOREIGN KEY `service_metadata_ibfk_1`; 24 | ALTER TABLE health_check DROP FOREIGN KEY `health_check_ibfk_1`; 25 | ALTER TABLE circuitbreaker_rule_relation DROP FOREIGN KEY `circuitbreaker_rule_relation_ibfk_1`; 26 | -------------------------------------------------------------------------------- /cache/config.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package cache 19 | 20 | import "time" 21 | 22 | // Config 缓存配置 23 | type Config struct { 24 | // DiffTime 设置拉取时间范围, [T1 - abs(DiffTime), T1] 25 | DiffTime time.Duration `yaml:"diffTime"` 26 | // ReportInterval 监控数据上报周期 27 | ReportInterval time.Duration `yaml:"reportInterval"` 28 | } 29 | 30 | var ( 31 | config *Config 32 | ) 33 | 34 | // SetCacheConfig 设置缓存配置 35 | func SetCacheConfig(conf *Config) { 36 | config = conf 37 | } 38 | -------------------------------------------------------------------------------- /common/utils/funcs_test.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package utils 19 | 20 | import ( 21 | "testing" 22 | 23 | "github.com/stretchr/testify/assert" 24 | ) 25 | 26 | func TestNewUUID(t *testing.T) { 27 | val := NewUUID() 28 | t.Log(val) 29 | } 30 | 31 | func TestStringSliceDeDuplication(t *testing.T) { 32 | s := []string{"1", "2", "", "_invalid", "1", "23"} 33 | s2 := StringSliceDeDuplication(s) 34 | assert.Equal(t, s2, []string{"1", "2", "", "_invalid", "23"}) 35 | } 36 | -------------------------------------------------------------------------------- /common/utils/reflect.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package utils 19 | 20 | import ( 21 | "reflect" 22 | "unsafe" 23 | ) 24 | 25 | func SetUnexportedField(field reflect.Value, value interface{}) { 26 | reflect.NewAt(field.Type(), unsafe.Pointer(field.UnsafeAddr())). 27 | Elem(). 28 | Set(reflect.ValueOf(value)) 29 | } 30 | 31 | func GetUnexportedField(field reflect.Value) interface{} { 32 | return reflect.NewAt(field.Type(), unsafe.Pointer(field.UnsafeAddr())).Elem().Interface() 33 | } 34 | -------------------------------------------------------------------------------- /apiserver/nacosserver/logger/log.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package logger 19 | 20 | import ( 21 | commonlog "github.com/polarismesh/polaris/common/log" 22 | ) 23 | 24 | var ( 25 | nacoslog = commonlog.RegisterScope("nacos-apiserver", "nacos apiserver plugin", 0) 26 | tracelog = commonlog.RegisterScope("nacos-trace", "nacos trace", 0) 27 | ) 28 | 29 | func GetNacosLog() *commonlog.Scope { 30 | return nacoslog 31 | } 32 | 33 | func GetTraceLog() *commonlog.Scope { 34 | return tracelog 35 | } 36 | -------------------------------------------------------------------------------- /release/tool/check.sh: -------------------------------------------------------------------------------- 1 | # Tencent is pleased to support the open source community by making Polaris available. 2 | # 3 | # Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 4 | # 5 | # Licensed under the BSD 3-Clause License (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://opensource.org/licenses/BSD-3-Clause 10 | # 11 | # Unless required by applicable law or agreed to in writing, software distributed 12 | # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | # CONDITIONS OF ANY KIND, either express or implied. See the License for the 14 | # specific language governing permissions and limitations under the License. 15 | #!/bin/bash 16 | 17 | curpath=$(pwd) 18 | 19 | if [ "${0:0:1}" == "/" ]; then 20 | dir=$(dirname "$0") 21 | else 22 | dir=$(pwd)/$(dirname "$0") 23 | fi 24 | 25 | cd $dir/.. 26 | workdir=$(pwd) 27 | 28 | #------------------------------------------------------ 29 | source tool/include 30 | 31 | pids=$(ps -ef | grep -w "$cmdline" | grep -v "grep" | awk '{print $2}') 32 | array=($pids) 33 | if [ "${#array[@]}" == "0" ]; then 34 | start 35 | fi 36 | 37 | #------------------------------------------------------ 38 | 39 | cd $curpath 40 | -------------------------------------------------------------------------------- /cmd/root.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/spf13/cobra" 22 | ) 23 | 24 | var ( 25 | rootCmd = &cobra.Command{ 26 | Use: "polaris-server", 27 | Short: "polaris server", 28 | Long: "polaris server", 29 | SilenceUsage: true, 30 | } 31 | ) 32 | 33 | // init 初始化命令行工具 34 | func init() { 35 | rootCmd.AddCommand(startCmd) 36 | rootCmd.AddCommand(versionCmd) 37 | rootCmd.AddCommand(revisionCmd) 38 | } 39 | 40 | // Execute 执行命令行解析 41 | func Execute() { 42 | _ = rootCmd.Execute() 43 | } 44 | -------------------------------------------------------------------------------- /apiserver/nacosserver/model/error.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package model 19 | 20 | import ( 21 | "github.com/polarismesh/polaris/common/utils" 22 | ) 23 | 24 | type NacosApiError struct { 25 | DetailErrCode int32 26 | ErrAbstract string 27 | Err *NacosError 28 | } 29 | 30 | func (e *NacosApiError) Error() string { 31 | return utils.MustJson(e) 32 | } 33 | 34 | type NacosError struct { 35 | ErrCode int32 36 | ErrMsg string 37 | CauseErr error 38 | } 39 | 40 | func (e *NacosError) Error() string { 41 | return utils.MustJson(e) 42 | } 43 | -------------------------------------------------------------------------------- /test/integrate/grpc/config_center.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package grpc 19 | 20 | import ( 21 | "context" 22 | 23 | apiconfig "github.com/polarismesh/specification/source/go/api/v1/config_manage" 24 | ) 25 | 26 | func (c *Client) GetConfigFile(ctx context.Context, in *apiconfig.ClientConfigFileInfo) (*apiconfig.ConfigClientResponse, error) { 27 | return nil, nil 28 | } 29 | 30 | // 订阅配置变更 31 | func (c *Client) WatchConfigFiles(ctx context.Context, in *apiconfig.ClientWatchConfigFileRequest) (*apiconfig.ConfigClientResponse, error) { 32 | return nil, nil 33 | } 34 | -------------------------------------------------------------------------------- /common/version/version.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package version 19 | 20 | var ( 21 | // Version version 22 | Version string 23 | // BuildDate build date 24 | BuildDate string 25 | ) 26 | 27 | const defaultVersion = "v0.1.0" 28 | 29 | // Get 获取版本号 30 | func Get() string { 31 | if Version == "" { 32 | return defaultVersion 33 | } 34 | 35 | return Version 36 | } 37 | 38 | // GetRevision 获取完整版本号信息,包括时间戳的 39 | func GetRevision() string { 40 | if Version == "" || BuildDate == "" { 41 | return defaultVersion 42 | } 43 | 44 | return Version + "." + BuildDate 45 | } 46 | -------------------------------------------------------------------------------- /plugin/plugin_test.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package plugin 19 | 20 | import ( 21 | "testing" 22 | 23 | "github.com/polarismesh/polaris/common/metrics" 24 | ) 25 | 26 | func Test_Statis(t *testing.T) { 27 | SetPluginConfig(&Config{ 28 | Statis: PluginChanConfig{ 29 | Entries: []ConfigEntry{ 30 | { 31 | Name: "local", 32 | }, 33 | { 34 | Name: "prometheus", 35 | }, 36 | }, 37 | }, 38 | }) 39 | 40 | ts := GetStatis() 41 | 42 | ts.ReportCallMetrics(metrics.CallMetric{}) 43 | ts.ReportDiscoverCall(metrics.ClientDiscoverMetric{}) 44 | } 45 | -------------------------------------------------------------------------------- /.github/workflows/licence-checker.yml: -------------------------------------------------------------------------------- 1 | # Tencent is pleased to support the open source community by making Polaris available. 2 | # 3 | # Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 4 | # 5 | # Licensed under the BSD 3-Clause License (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://opensource.org/licenses/BSD-3-Clause 10 | # 11 | # Unless required by applicable law or agreed to in writing, software distributed 12 | # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | # CONDITIONS OF ANY KIND, either express or implied. See the License for the 14 | # specific language governing permissions and limitations under the License. 15 | 16 | name: License checker 17 | 18 | on: 19 | push: 20 | branches: 21 | - main 22 | - release* 23 | pull_request: 24 | branches: 25 | - main 26 | - release* 27 | 28 | jobs: 29 | check-license: 30 | runs-on: ubuntu-latest 31 | steps: 32 | - uses: actions/checkout@v2 33 | 34 | - name: Check License Header 35 | uses: apache/skywalking-eyes@main 36 | env: 37 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 38 | with: 39 | log: info 40 | config: .licenserc.yaml 41 | -------------------------------------------------------------------------------- /store/mysql/sql_test.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package sqldb 19 | 20 | import ( 21 | "testing" 22 | 23 | . "github.com/smartystreets/goconvey/convey" 24 | ) 25 | 26 | // TestPlaceholdersN 构造占位符的测试 27 | func TestPlaceholdersN(t *testing.T) { 28 | Convey("可以正常输出", t, func() { 29 | So(PlaceholdersN(-1), ShouldBeEmpty) 30 | So(PlaceholdersN(1), ShouldEqual, "?") 31 | So(PlaceholdersN(3), ShouldEqual, "?,?,?") 32 | }) 33 | } 34 | 35 | func Test_Quick(t *testing.T) { 36 | slice := make([]string, 0, 1) 37 | slice = nil 38 | for i := range slice { 39 | t.Log(slice[i]) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /release/cluster/kubernetes/07-polaris-limiter.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: StatefulSet 3 | metadata: 4 | labels: 5 | app: polaris-limiter 6 | name: polaris-limiter 7 | namespace: polaris-system 8 | spec: 9 | podManagementPolicy: OrderedReady 10 | replicas: 1 11 | selector: 12 | matchLabels: 13 | app: polaris-limiter 14 | serviceName: polaris-limiter 15 | template: 16 | metadata: 17 | labels: 18 | app: polaris-limiter 19 | spec: 20 | containers: 21 | - image: polarismesh/polaris-limiter:##POLARIS_LIMITER_VERSION## 22 | imagePullPolicy: Always 23 | name: polaris-limiter 24 | resources: 25 | limits: 26 | cpu: "500m" 27 | memory: 1000Mi 28 | terminationMessagePath: /dev/termination-log 29 | terminationMessagePolicy: File 30 | volumeMounts: 31 | - mountPath: /root/polaris-limiter.yaml.example 32 | name: polaris-limiter-config 33 | subPath: polaris-limiter.yaml 34 | restartPolicy: Always 35 | volumes: 36 | - configMap: 37 | defaultMode: 0640 38 | name: polaris-limiter-config 39 | name: polaris-limiter-config 40 | updateStrategy: 41 | rollingUpdate: 42 | partition: 0 43 | type: RollingUpdate 44 | -------------------------------------------------------------------------------- /apiserver/httpserver/discover/v2/proto.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package v2 19 | 20 | import ( 21 | "github.com/golang/protobuf/proto" 22 | apitraffic "github.com/polarismesh/specification/source/go/api/v1/traffic_manage" 23 | ) 24 | 25 | // RoutingArr 路由规则数组定义 26 | type RoutingArr []*apitraffic.RouteRule 27 | 28 | // Reset reset initialization 29 | func (m *RoutingArr) Reset() { *m = RoutingArr{} } 30 | 31 | // String return string 32 | func (m *RoutingArr) String() string { return proto.CompactTextString(m) } 33 | 34 | // ProtoMessage return proto message 35 | func (*RoutingArr) ProtoMessage() {} 36 | -------------------------------------------------------------------------------- /cmd/start.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/spf13/cobra" 22 | 23 | "github.com/polarismesh/polaris/bootstrap" 24 | ) 25 | 26 | var ( 27 | configFilePath = "" 28 | 29 | startCmd = &cobra.Command{ 30 | Use: "start", 31 | Short: "start running", 32 | Long: "start running", 33 | Run: func(c *cobra.Command, args []string) { 34 | bootstrap.Start(configFilePath) 35 | }, 36 | } 37 | ) 38 | 39 | // init 解析命令参数 40 | func init() { 41 | startCmd.PersistentFlags().StringVarP(&configFilePath, "config", "c", "conf/polaris-server.yaml", "config file path") 42 | } 43 | -------------------------------------------------------------------------------- /release/standalone/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:centos7.9.2009 2 | 3 | ARG SERVER_VERSION=v1.12.0 4 | ARG CONSOLE_VERSION=v1.9.0 5 | ARG LIMITER_VERSION=v1.0.2 6 | ARG GOOS=linux 7 | ARG TARGETARCH=amd64 8 | 9 | LABEL cn.polarismesh.image.authors="polaris" 10 | LABEL cn.polarismesh.image.documentation="https://polarismesh.cn/#/" 11 | 12 | RUN yum install -y lsof curl unzip vixie-cron crontabs net-tools 13 | 14 | COPY polaris-server-release_${SERVER_VERSION}.${GOOS}.${TARGETARCH}.zip /root/polaris-server-release_${SERVER_VERSION}.${GOOS}.${TARGETARCH}.zip 15 | COPY polaris-console-release_${CONSOLE_VERSION}.${GOOS}.${TARGETARCH}.zip /root/polaris-console-release_${CONSOLE_VERSION}.${GOOS}.${TARGETARCH}.zip 16 | COPY polaris-limiter-release_${LIMITER_VERSION}.${GOOS}.${TARGETARCH}.zip /root/polaris-limiter-release_${LIMITER_VERSION}.${GOOS}.${TARGETARCH}.zip 17 | COPY prometheus-2.28.0.${GOOS}-${TARGETARCH}.tar.gz /root/prometheus-2.28.0.${GOOS}-${TARGETARCH}.tar.gz 18 | COPY pushgateway-1.6.0.${GOOS}-${TARGETARCH}.tar.gz /root/pushgateway-1.6.0.${GOOS}-${TARGETARCH}.tar.gz 19 | COPY install.sh /root/install.sh 20 | COPY prometheus-help.sh /root/prometheus-help.sh 21 | COPY port.properties /root/port.properties 22 | COPY run.sh /root/run.sh 23 | 24 | WORKDIR /root 25 | 26 | EXPOSE 8091 8090 8761 8093 8080 8100 8101 15010 9090 9091 27 | 28 | CMD ["/bin/bash", "run.sh"] 29 | -------------------------------------------------------------------------------- /apiserver/nacosserver/v2/pb/nacos_grpc_service.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2020 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | syntax = "proto3"; 18 | 19 | import "google/protobuf/any.proto"; 20 | 21 | option java_multiple_files = true; 22 | option java_package = "com.alibaba.nacos.api.grpc.auto"; 23 | 24 | message Metadata { 25 | string type = 3; 26 | string clientIp = 8; 27 | map headers = 7; 28 | } 29 | 30 | message Payload { 31 | Metadata metadata = 2; 32 | google.protobuf.Any body = 3; 33 | } 34 | 35 | service Request { 36 | // Sends a commonRequest 37 | rpc request(Payload) returns (Payload) {} 38 | } 39 | 40 | service BiRequestStream { 41 | // Sends a commonRequest 42 | rpc requestBiStream(stream Payload) returns (stream Payload) {} 43 | } -------------------------------------------------------------------------------- /release/standalone/docker-compose/grafana/provisioning/datasources/datasource.yml: -------------------------------------------------------------------------------- 1 | # config file version 2 | apiVersion: 1 3 | 4 | # list of datasources to insert/update 5 | datasources: 6 | # name of the datasource. Required 7 | - name: Prometheus 8 | # datasource type. Required 9 | type: prometheus 10 | # access mode. proxy or direct (Server or Browser in the UI). Required 11 | access: proxy 12 | # org id. will default to orgId 1 if not specified 13 | orgId: 1 14 | # custom UID which can be used to reference this datasource in other parts of the configuration, if not specified will be generated automatically 15 | # uid: my_unique_uid 16 | # url 17 | url: "http://polaris-prometheus:9090" 18 | user: 19 | # database name 20 | database: 21 | # allow updating provisioned dashboards from the UI 22 | allowUiUpdates: true 23 | # mark as default datasource. Max one per org 24 | isDefault: true 25 | # fields that will be converted to json and stored in jsonData 26 | jsonData: 27 | httpMethod: POST 28 | secureJsonData: 29 | # database password, if used 30 | password: "" 31 | version: 1 32 | # allow users to edit datasources from the UI. 33 | editable: true 34 | -------------------------------------------------------------------------------- /common/utils/atomic.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package utils 19 | 20 | import "sync/atomic" 21 | 22 | func NewAtomicValue[V any](v V) *AtomicValue[V] { 23 | a := new(AtomicValue[V]) 24 | a.a = atomic.Value{} 25 | a.Store(v) 26 | return a 27 | } 28 | 29 | type AtomicValue[V any] struct { 30 | a atomic.Value 31 | } 32 | 33 | func (a *AtomicValue[V]) HasValue() bool { 34 | if a == nil { 35 | return false 36 | } 37 | v := a.a.Load() 38 | return v != nil 39 | } 40 | 41 | func (a *AtomicValue[V]) Store(val V) { 42 | a.a.Store(val) 43 | } 44 | 45 | func (a *AtomicValue[V]) Load() V { 46 | return a.a.Load().(V) 47 | } 48 | -------------------------------------------------------------------------------- /cache/service/default.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package service 19 | 20 | import ( 21 | types "github.com/polarismesh/polaris/cache/api" 22 | ) 23 | 24 | var ( 25 | _ types.InstanceCache = (*instanceCache)(nil) 26 | _ types.ServiceCache = (*serviceCache)(nil) 27 | _ types.RoutingConfigCache = (*RouteRuleCache)(nil) 28 | _ types.CircuitBreakerCache = (*circuitBreakerCache)(nil) 29 | _ types.RateLimitCache = (*rateLimitCache)(nil) 30 | _ types.FaultDetectCache = (*faultDetectCache)(nil) 31 | _ types.L5Cache = (*l5Cache)(nil) 32 | _ types.FaultDetectCache = (*faultDetectCache)(nil) 33 | ) 34 | -------------------------------------------------------------------------------- /release/README-zh.md: -------------------------------------------------------------------------------- 1 | # 安装指南 2 | 3 | [English](./README.md) | [简体中文](./README-zh.md) 4 | 5 | 索引: 6 | 7 | - [如何安装](#如何安装) 8 | - [单机版安装](#单机安装) 9 | - [集群版安装](#集群安装) 10 | - [如何验证](#如何验证) 11 | 12 | ## 如何安装 13 | 14 | 单机版和集群版均支持Linux、Mac和Windows各类操作系统,安装包获取路径如下: 15 | 16 | - [Github Releases](https://github.com/polarismesh/polaris/releases) 17 | - [Gitee Releases](https://gitee.com/polarismesh/polaris/releases) 18 | 19 | ### 单机版安装 20 | 21 | **Linux操作系统环境** 22 | 23 | 请下载名称为 `polaris-standalone-release-*.linux.*.zip`的包。 24 | 25 | ``` 26 | unzip polaris-standalone-release-*.linux.*.zip 27 | 28 | cd polaris-standalone-release-*.linux.* 29 | 30 | bash install.sh 31 | ``` 32 | 33 | **Mac操作系统环境** 34 | 35 | 请下载名称为 `polaris-standalone-release-*.darwin.*.zip`的包。 36 | 37 | ``` 38 | unzip polaris-standalone-release-*.darwin.*.zip 39 | 40 | cd polaris-standalone-release-*.darwin.* 41 | 42 | bash install.sh 43 | ``` 44 | 45 | **Windows操作系统环境** 46 | 47 | 请下载名称为 `polaris-standalone-release-*.windows.*.zip`的包。 48 | 49 | ``` 50 | unzip polaris-standalone-release-*.windows.*.zip 51 | 52 | cd polaris-standalone-release-*.windows.* 53 | 54 | install.bat 55 | ``` 56 | 57 | ### 集群版安装 58 | 59 | todo 60 | 61 | ## 如何验证 62 | 63 | 可以使用浏览器访问`http://127.0.0.1:8090`,或在命令行下执行下面的命令来验证安装是否成功: 64 | 65 | ``` 66 | curl http://127.0.0.1:8090 67 | ``` 68 | 69 | 如果显示"Polaris Server"则表示安装成功。 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /release/Dockerfile: -------------------------------------------------------------------------------- 1 | # Tencent is pleased to support the open source community by making Polaris available. 2 | # 3 | # Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 4 | # 5 | # Licensed under the BSD 3-Clause License (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://opensource.org/licenses/BSD-3-Clause 10 | # 11 | # Unless required by applicable law or agreed to in writing, software distributed 12 | # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | # CONDITIONS OF ANY KIND, either express or implied. See the License for the 14 | # specific language governing permissions and limitations under the License. 15 | 16 | FROM alpine:3.13.6 17 | 18 | RUN sed -i 's!http://dl-cdn.alpinelinux.org/!https://mirrors.tencent.com/!g' /etc/apk/repositories 19 | 20 | RUN set -eux && \ 21 | apk add tcpdump && \ 22 | apk add tzdata && \ 23 | apk add busybox-extras && \ 24 | apk add curl && \ 25 | apk add bash && \ 26 | cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ 27 | echo "Asia/Shanghai" > /etc/timezone && \ 28 | date 29 | 30 | ARG TARGETARCH 31 | COPY polaris-server-${TARGETARCH} /root/polaris-server 32 | COPY ./release/conf /root/conf 33 | 34 | WORKDIR /root 35 | 36 | CMD ["/root/polaris-server", "start"] 37 | -------------------------------------------------------------------------------- /test/integrate/resource/client.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package resource 19 | 20 | import ( 21 | "fmt" 22 | 23 | apiservice "github.com/polarismesh/specification/source/go/api/v1/service_manage" 24 | 25 | "github.com/polarismesh/polaris/common/utils" 26 | ) 27 | 28 | const ( 29 | clientHost = "%v.%v.%v.%v" 30 | ) 31 | 32 | /** 33 | * @brief 创建客户端 34 | */ 35 | func CreateClient(index uint32) *apiservice.Client { 36 | return &apiservice.Client{ 37 | Host: utils.NewStringValue(fmt.Sprintf(clientHost, index, index, index, index)), 38 | Type: apiservice.Client_SDK, 39 | Version: utils.NewStringValue("8.8.8"), 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /auth/policy/test_export.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package policy 19 | 20 | import ( 21 | "github.com/polarismesh/polaris/auth" 22 | "github.com/polarismesh/polaris/store" 23 | ) 24 | 25 | // MockAuthChecker mock auth.AuthChecker for unit test 26 | func (svr *Server) MockAuthChecker(checker auth.AuthChecker) { 27 | svr.checker = checker 28 | } 29 | 30 | // MockStore mock store.Store for unit test 31 | func (svr *Server) MockStore(storage store.Store) { 32 | svr.storage = storage 33 | } 34 | 35 | // MockUserServer mock auth.UserServer for unit test 36 | func (svr *Server) MockUserServer(userSvr auth.UserServer) { 37 | svr.userSvr = userSvr 38 | } 39 | -------------------------------------------------------------------------------- /service/interceptor/paramcheck/cl5.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package paramcheck 19 | 20 | import ( 21 | "context" 22 | 23 | "github.com/polarismesh/polaris/common/api/l5" 24 | ) 25 | 26 | // RegisterByNameCmd implements service.DiscoverServer. 27 | func (svr *Server) RegisterByNameCmd(rbnc *l5.Cl5RegisterByNameCmd) (*l5.Cl5RegisterByNameAckCmd, error) { 28 | return svr.nextSvr.RegisterByNameCmd(rbnc) 29 | } 30 | 31 | // SyncByAgentCmd implements service.DiscoverServer. 32 | func (svr *Server) SyncByAgentCmd(ctx context.Context, sbac *l5.Cl5SyncByAgentCmd) (*l5.Cl5SyncByAgentAckCmd, error) { 33 | return svr.nextSvr.SyncByAgentCmd(ctx, sbac) 34 | } 35 | -------------------------------------------------------------------------------- /store/boltdb/l5_test.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package boltdb 19 | 20 | import ( 21 | "fmt" 22 | "testing" 23 | ) 24 | 25 | func TestL5Store_GenNextL5Sid(t *testing.T) { 26 | handler, err := NewBoltHandler(&BoltConfig{FileName: "./table.bolt"}) 27 | if err != nil { 28 | t.Fatal(err) 29 | } 30 | defer handler.Close() 31 | 32 | l5store := &l5Store{handler: handler} 33 | 34 | if err = l5store.InitL5Data(); err != nil { 35 | t.Fatal(err) 36 | } 37 | for i := 0; i < 10; i++ { 38 | sid, err := l5store.GenNextL5Sid(uint32(i+1) % 6) 39 | if err != nil { 40 | t.Fatal(err) 41 | } 42 | fmt.Printf("sid %d is %s\n", i, sid) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /admin/config.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package admin 19 | 20 | import ( 21 | "github.com/polarismesh/polaris/admin/job" 22 | ) 23 | 24 | // Config maintain configuration 25 | type Config struct { 26 | Jobs []job.JobConfig `yaml:"jobs"` 27 | Interceptors []string `yaml:"-"` 28 | } 29 | 30 | func DefaultConfig() *Config { 31 | return &Config{ 32 | Jobs: []job.JobConfig{ 33 | { 34 | Name: "CleanDeletedClients", 35 | Enable: true, 36 | }, 37 | { 38 | Name: "CleanDeletedInstances", 39 | Enable: true, 40 | }, 41 | { 42 | Name: "CleanConfigReleaseHistory", 43 | Enable: true, 44 | }, 45 | }, 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /store/boltdb/tx.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package boltdb 19 | 20 | import ( 21 | bolt "go.etcd.io/bbolt" 22 | 23 | "github.com/polarismesh/polaris/store" 24 | ) 25 | 26 | type Tx struct { 27 | delegateTx *bolt.Tx 28 | } 29 | 30 | func NewBoltTx(delegateTx *bolt.Tx) store.Tx { 31 | return &Tx{ 32 | delegateTx: delegateTx, 33 | } 34 | } 35 | 36 | func (t *Tx) Commit() error { 37 | return t.delegateTx.Commit() 38 | } 39 | 40 | func (t *Tx) Rollback() error { 41 | return t.delegateTx.Rollback() 42 | } 43 | 44 | func (t *Tx) GetDelegateTx() interface{} { 45 | return t.delegateTx 46 | } 47 | 48 | func (t *Tx) CreateReadView() error { 49 | return nil 50 | } 51 | -------------------------------------------------------------------------------- /admin/server.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package admin 19 | 20 | import ( 21 | "sync" 22 | 23 | "github.com/polarismesh/polaris/cache" 24 | "github.com/polarismesh/polaris/service" 25 | "github.com/polarismesh/polaris/service/healthcheck" 26 | "github.com/polarismesh/polaris/store" 27 | ) 28 | 29 | var _ AdminOperateServer = (*Server)(nil) 30 | 31 | type Server struct { 32 | mu sync.Mutex 33 | namingServer service.DiscoverServer 34 | healthCheckServer *healthcheck.Server 35 | cacheMgn *cache.CacheManager 36 | storage store.Store 37 | } 38 | 39 | func GetChainOrder() []string { 40 | return []string{ 41 | "auth", 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /service/healthcheck/test_export.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package healthcheck 19 | 20 | import ( 21 | "context" 22 | 23 | "github.com/polarismesh/polaris/service/batch" 24 | "github.com/polarismesh/polaris/store" 25 | ) 26 | 27 | func TestInitialize(ctx context.Context, hcOpt *Config, bc *batch.Controller, 28 | storage store.Store) (*Server, error) { 29 | hcOpt.SetDefault() 30 | testServer, err := NewHealthServer(ctx, hcOpt, 31 | WithStore(storage), 32 | WithBatchController(bc), 33 | WithTimeAdjuster(newTimeAdjuster(ctx, storage)), 34 | ) 35 | if err != nil { 36 | return nil, err 37 | } 38 | finishInit = true 39 | return testServer, testServer.run(ctx) 40 | } 41 | -------------------------------------------------------------------------------- /.github/workflows/weekly-report.yml: -------------------------------------------------------------------------------- 1 | # Tencent is pleased to support the open source community by making Polaris available. 2 | # 3 | # Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 4 | # 5 | # Licensed under the BSD 3-Clause License (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://opensource.org/licenses/BSD-3-Clause 10 | # 11 | # Unless required by applicable law or agreed to in writing, software distributed 12 | # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | # CONDITIONS OF ANY KIND, either express or implied. See the License for the 14 | # specific language governing permissions and limitations under the License. 15 | 16 | name: weekly-report 17 | 18 | on: 19 | schedule: 20 | - cron: "0 10 * * 1" 21 | 22 | jobs: 23 | create_issue: 24 | runs-on: ubuntu-latest 25 | steps: 26 | - name: Get today's date 27 | id: date 28 | run: | 29 | echo "::set-output name=today::$(date "+%Y-%m-%d")" 30 | - name: Create an issue 31 | uses: actions-ecosystem/action-create-issue@v1.0.0 32 | with: 33 | github_token: ${{ secrets.weekly_token }} 34 | title: "[Polaris Weekly Report] ${{ steps.date.outputs.today }}" 35 | body: | 36 | ## Polaris Weekly Report 37 | labels: | 38 | weekly-report 39 | -------------------------------------------------------------------------------- /store/mysql/tx.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package sqldb 19 | 20 | import "github.com/polarismesh/polaris/store" 21 | 22 | type Tx struct { 23 | delegateTx *BaseTx 24 | } 25 | 26 | func NewSqlDBTx(delegateTx *BaseTx) store.Tx { 27 | return &Tx{ 28 | delegateTx: delegateTx, 29 | } 30 | } 31 | 32 | func (t *Tx) Commit() error { 33 | return t.delegateTx.Commit() 34 | } 35 | 36 | func (t *Tx) Rollback() error { 37 | return t.delegateTx.Rollback() 38 | } 39 | 40 | func (t *Tx) GetDelegateTx() interface{} { 41 | return t.delegateTx 42 | } 43 | 44 | func (t *Tx) CreateReadView() error { 45 | tx := t.delegateTx 46 | _, err := tx.Exec("START TRANSACTION WITH CONSISTENT SNAPSHOT") 47 | return err 48 | } 49 | -------------------------------------------------------------------------------- /config/options.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package config 19 | 20 | import ( 21 | "os" 22 | "path/filepath" 23 | 24 | cachetypes "github.com/polarismesh/polaris/cache/api" 25 | "github.com/polarismesh/polaris/common/utils" 26 | ) 27 | 28 | var ( 29 | configCacheEntries = []cachetypes.ConfigEntry{ 30 | { 31 | Name: "configFile", 32 | }, 33 | { 34 | Name: "configGroup", 35 | }, 36 | } 37 | ) 38 | 39 | var ( 40 | testConfigCacheEntries = []cachetypes.ConfigEntry{ 41 | { 42 | Name: "configFile", 43 | Option: map[string]interface{}{ 44 | "cachePath": filepath.Join(os.TempDir(), "/polaris/cache/", utils.NewUUID()), 45 | }, 46 | }, 47 | { 48 | Name: "configGroup", 49 | }, 50 | } 51 | ) 52 | -------------------------------------------------------------------------------- /plugin/whitelist.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package plugin 19 | 20 | import ( 21 | "os" 22 | "sync" 23 | ) 24 | 25 | var ( 26 | whitelistOnce sync.Once 27 | ) 28 | 29 | // Whitelist White list interface 30 | type Whitelist interface { 31 | Plugin 32 | 33 | Contain(entry interface{}) bool 34 | } 35 | 36 | // GetWhitelist Get the whitelist plugin 37 | func GetWhitelist() Whitelist { 38 | c := &config.Whitelist 39 | plugin, exist := pluginSet[c.Name] 40 | if !exist { 41 | return nil 42 | } 43 | whitelistOnce.Do(func() { 44 | if err := plugin.Initialize(c); err != nil { 45 | log.Errorf("Whitelist plugin init err: %s", err.Error()) 46 | os.Exit(-1) 47 | } 48 | }) 49 | return plugin.(Whitelist) 50 | } 51 | -------------------------------------------------------------------------------- /release/standalone/docker-compose/limiter/polaris-limiter.yaml: -------------------------------------------------------------------------------- 1 | registry: 2 | enable: true 3 | polaris-server-address: polaris-server:8091 4 | name: polaris.limiter 5 | namespace: Polaris 6 | health-check-enable: true 7 | api-servers: 8 | - name: http 9 | option: 10 | ip: 0.0.0.0 11 | port: 8100 12 | - name: grpc 13 | option: 14 | ip: 0.0.0.0 15 | port: 8101 16 | limit: 17 | myid: 1 #节点ID,集群中不同节点需设置不同的myid 18 | counter-group: 64 # 计数器分组,不同组的计数器创建时不冲突 19 | max-counter: 1000000 20 | max-client: 1000 21 | push-worker: 4 22 | slide-count: 1 23 | purge-counter-interval: 30s 24 | sync-remote-storage-interval: 1m 25 | async-remote-wait-timeout: 200ms 26 | update-remote-storage-threshold: 10m 27 | flush-local-storage-threshold: 3s 28 | plugin: 29 | statis: 30 | name: file 31 | option: 32 | ratelimit-app-name: 294_4423_polaris-limiter-stat #限流监控 33 | ratelimit_report_log_path: log/polaris-limiter-ratelimit-report.log 34 | ratelimit_event_log_path: log/polaris-limiter-event.log 35 | ratelimit_precision_log_path: log/polaris-limiter-stat.log 36 | server-app-name: 294_11866_polaris_limit_server #服务端监控 37 | server_report_log_path: log/polaris-limiter-server-report.log 38 | log_interval: 60 39 | precision_log_interval: 1 40 | logger: 41 | RotateOutputPath: log/polaris-limiter.log 42 | RotationMaxSize: 500 43 | RotationMaxAge: 30 44 | RotationMaxBackups: 100 45 | level: info 46 | -------------------------------------------------------------------------------- /common/conn/hook/conn.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package connhook 19 | 20 | import ( 21 | "net" 22 | "sync" 23 | ) 24 | 25 | // Conn 包装net.Conn 26 | // 目的:拦截Close操作,用于listener计数的Release以及activeConns的删除 27 | type Conn struct { 28 | net.Conn 29 | releaseOnce sync.Once 30 | closed bool 31 | listener *HookListener 32 | } 33 | 34 | // Close 包装net.Conn.Close, 用于连接计数 35 | func (c *Conn) Close() error { 36 | if c.closed { 37 | return nil 38 | } 39 | 40 | err := c.Conn.Close() 41 | c.releaseOnce.Do(func() { 42 | // 调用监听的listener,释放计数以及activeConns 43 | // 保证只执行一次 44 | c.closed = true 45 | 46 | for i := range c.listener.hooks { 47 | c.listener.hooks[i].OnRelease(c) 48 | } 49 | 50 | }) 51 | return err 52 | } 53 | -------------------------------------------------------------------------------- /cmd/version.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package cmd 19 | 20 | import ( 21 | "fmt" 22 | 23 | "github.com/spf13/cobra" 24 | 25 | "github.com/polarismesh/polaris/common/version" 26 | ) 27 | 28 | var ( 29 | versionCmd = &cobra.Command{ 30 | Use: "version", 31 | Short: "print version", 32 | Long: "print version", 33 | Run: func(c *cobra.Command, args []string) { 34 | fmt.Printf("version: %v\n", version.Get()) 35 | }, 36 | } 37 | 38 | revisionCmd = &cobra.Command{ 39 | Use: "revision", 40 | Short: "print revision with building date", 41 | Long: "print revision with building date", 42 | Run: func(cmd *cobra.Command, args []string) { 43 | fmt.Printf("revision: %v\n", version.GetRevision()) 44 | }, 45 | } 46 | ) 47 | -------------------------------------------------------------------------------- /auth/testexport.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package auth 19 | 20 | import ( 21 | "context" 22 | 23 | cachetypes "github.com/polarismesh/polaris/cache/api" 24 | "github.com/polarismesh/polaris/store" 25 | ) 26 | 27 | // TestInitialize 包裹了初始化函数,在 Initialize 的时候会在自动调用,全局初始化一次 28 | func TestInitialize(ctx context.Context, authOpt *Config, storage store.Store, 29 | cacheMgn cachetypes.CacheManager) (UserServer, StrategyServer, error) { 30 | userSvr, strategySvr, err := initialize(ctx, authOpt, storage, cacheMgn) 31 | if err != nil { 32 | return nil, nil, err 33 | } 34 | userMgn = userSvr 35 | strategyMgn = strategySvr 36 | return userSvr, strategySvr, nil 37 | } 38 | 39 | func TestClean() { 40 | userMgn = nil 41 | strategyMgn = nil 42 | } 43 | -------------------------------------------------------------------------------- /service/interceptor/auth/l5_service.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package service_auth 19 | 20 | import ( 21 | "context" 22 | 23 | "github.com/polarismesh/polaris/common/api/l5" 24 | ) 25 | 26 | // SyncByAgentCmd 根据sid获取路由信息 27 | // 老函数: 28 | // Stat::instance()->inc_sync_req_cnt(); 29 | // 保存client的IP,该函数只是存储到本地的缓存中 30 | // Stat::instance()->add_agent(sbac.agent_ip()); 31 | func (svr *Server) SyncByAgentCmd(ctx context.Context, sbac *l5.Cl5SyncByAgentCmd) ( 32 | *l5.Cl5SyncByAgentAckCmd, error) { 33 | return svr.nextSvr.SyncByAgentCmd(ctx, sbac) 34 | } 35 | 36 | // RegisterByNameCmd 根据名字获取sid信息 37 | func (svr *Server) RegisterByNameCmd(rbnc *l5.Cl5RegisterByNameCmd) (*l5.Cl5RegisterByNameAckCmd, error) { 38 | return svr.nextSvr.RegisterByNameCmd(rbnc) 39 | } 40 | -------------------------------------------------------------------------------- /plugin/password/parse.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package password 19 | 20 | import "github.com/polarismesh/polaris/plugin" 21 | 22 | const ( 23 | PluginName = "localParse" 24 | ) 25 | 26 | // init 初始化注册函数 27 | func init() { 28 | plugin.RegisterPlugin(PluginName, &Password{}) 29 | } 30 | 31 | // Password 密码插件 32 | type Password struct{} 33 | 34 | // Name 返回插件名字 35 | func (p *Password) Name() string { 36 | return PluginName 37 | } 38 | 39 | // Destroy 销毁插件 40 | func (p *Password) Destroy() error { 41 | return nil 42 | } 43 | 44 | // Initialize 插件初始化 45 | func (p *Password) Initialize(c *plugin.ConfigEntry) error { 46 | return nil 47 | } 48 | 49 | // ParsePassword 解析密码 50 | func (p *Password) ParsePassword(cipher string) (string, error) { 51 | return "", nil 52 | } 53 | -------------------------------------------------------------------------------- /plugin/password.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package plugin 19 | 20 | import ( 21 | "os" 22 | "sync" 23 | ) 24 | 25 | var ( 26 | passwordOnce sync.Once 27 | ) 28 | 29 | // ParsePassword Password plug -in 30 | type ParsePassword interface { 31 | Plugin 32 | ParsePassword(cipher string) (string, error) 33 | } 34 | 35 | // GetParsePassword Get the parsing password plug -in 36 | func GetParsePassword() ParsePassword { 37 | c := &config.ParsePassword 38 | plugin, exist := pluginSet[c.Name] 39 | if !exist { 40 | return nil 41 | } 42 | 43 | passwordOnce.Do(func() { 44 | if err := plugin.Initialize(c); err != nil { 45 | log.Errorf("ParsePassword plugin init err: %s", err.Error()) 46 | os.Exit(-1) 47 | } 48 | }) 49 | 50 | return plugin.(ParsePassword) 51 | } 52 | -------------------------------------------------------------------------------- /release/standalone/docker-compose/console/polaris-console.yaml: -------------------------------------------------------------------------------- 1 | # Tencent is pleased to support the open source community by making Polaris available. 2 | # 3 | # Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 4 | # 5 | # Licensed under the BSD 3-Clause License (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://opensource.org/licenses/BSD-3-Clause 10 | # 11 | # Unless required by applicable law or agreed to in writing, software distributed 12 | # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | # CONDITIONS OF ANY KIND, either express or implied. See the License for the 14 | # specific language governing permissions and limitations under the License. 15 | 16 | logger: 17 | RotateOutputPath: log/polaris-console.log 18 | RotationMaxSize: 500 19 | RotationMaxAge: 30 20 | RotationMaxBackups: 100 21 | level: info 22 | webServer: 23 | mode: "release" 24 | listenIP: "0.0.0.0" 25 | listenPort: 8080 26 | jwt: 27 | secretKey: "polarismesh@2021" 28 | expired: 1800 29 | namingV1URL: "/naming/v1" 30 | namingV2URL: "/naming/v2" 31 | authURL: "/core/v1" 32 | configURL: "/config/v1" 33 | monitorURL: "/api/v1" 34 | webPath: "web/dist/" 35 | polarisServer: 36 | address: "polaris-server:8090" 37 | polarisToken: "nu/0WRA4EqSR1FagrjRj0fZwPXuGlMpX+zCuWu4uMqy8xr1vRjisSbA25aAC3mtU8MeeRsKhQiDAynUR09I=" 38 | monitorServer: 39 | address: "polaris-prometheus:9090" 40 | -------------------------------------------------------------------------------- /service/l5_service_test.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package service 19 | 20 | import ( 21 | "reflect" 22 | "testing" 23 | ) 24 | 25 | func TestComputeNamespace(t *testing.T) { 26 | type args struct { 27 | modID uint32 28 | cmdID uint32 29 | } 30 | tests := []struct { 31 | name string 32 | args args 33 | want []string 34 | }{ 35 | { 36 | name: "string", 37 | args: args{ 38 | modID: 192000065, 39 | cmdID: 65000, 40 | }, 41 | want: []string{ProductionNamespace}, 42 | }, 43 | } 44 | for _, tt := range tests { 45 | t.Run(tt.name, func(t *testing.T) { 46 | if got := ComputeNamespace(tt.args.modID, tt.args.cmdID); !reflect.DeepEqual(got, tt.want) { 47 | t.Errorf("ComputeNamespace() = %v, want %v", got, tt.want) 48 | } 49 | }) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /cache/config/config_group_metrics.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package config 19 | 20 | import ( 21 | "github.com/polarismesh/polaris/common/metrics" 22 | "github.com/polarismesh/polaris/common/model" 23 | "github.com/polarismesh/polaris/common/utils" 24 | "github.com/polarismesh/polaris/plugin" 25 | ) 26 | 27 | func (fc *configGroupCache) reportMetricsInfo() { 28 | fc.name2groups.Range(func(ns string, val *utils.SyncMap[string, *model.ConfigFileGroup]) { 29 | count := val.Len() 30 | reportValue := metrics.ConfigMetrics{ 31 | Type: metrics.ConfigGroupMetric, 32 | Total: int64(count), 33 | Release: 0, 34 | Labels: map[string]string{ 35 | metrics.LabelNamespace: ns, 36 | }, 37 | } 38 | plugin.GetStatis().ReportConfigMetrics(reportValue) 39 | }) 40 | 41 | } 42 | -------------------------------------------------------------------------------- /release/cluster/helm/templates/polaris-limiter.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: StatefulSet 3 | metadata: 4 | labels: 5 | app: polaris-limiter 6 | name: polaris-limiter 7 | namespace: {{ .Values.installation.namespace }} 8 | spec: 9 | podManagementPolicy: OrderedReady 10 | replicas: {{ .Values.polaris.limiterReplicaCount }} 11 | selector: 12 | matchLabels: 13 | app: polaris-limiter 14 | serviceName: polaris-limiter 15 | template: 16 | metadata: 17 | labels: 18 | app: polaris-limiter 19 | spec: 20 | containers: 21 | - image: {{ .Values.polaris.limiter.image.repository }}:{{ .Values.polaris.limiter.image.tag }} 22 | imagePullPolicy: {{ .Values.polaris.limiter.image.pullPolicy }} 23 | name: polaris-limiter 24 | resources: 25 | limits: 26 | cpu: {{ .Values.polaris.limiter.limit.cpu }} 27 | memory: {{ .Values.polaris.limiter.limit.memory }} 28 | terminationMessagePath: /dev/termination-log 29 | terminationMessagePolicy: File 30 | volumeMounts: 31 | - mountPath: /root/polaris-limiter.yaml.example 32 | name: polaris-limiter-config 33 | subPath: polaris-limiter.yaml 34 | restartPolicy: Always 35 | volumes: 36 | - configMap: 37 | defaultMode: 0640 38 | name: polaris-limiter-config 39 | name: polaris-limiter-config 40 | updateStrategy: 41 | rollingUpdate: 42 | partition: 0 43 | type: RollingUpdate 44 | -------------------------------------------------------------------------------- /release/tool/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Tencent is pleased to support the open source community by making Polaris available. 3 | # 4 | # Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | # 6 | # Licensed under the BSD 3-Clause License (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://opensource.org/licenses/BSD-3-Clause 11 | # 12 | # Unless required by applicable law or agreed to in writing, software distributed 13 | # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | # CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations under the License. 16 | 17 | enable_cron="false" 18 | 19 | for arg in "$@" 20 | do 21 | if [[ "${arg}" == "--enable-cron" ]]; then 22 | enable_cron="true" 23 | fi 24 | done 25 | 26 | curpath=$(pwd) 27 | 28 | if [ "${0:0:1}" == "/" ]; then 29 | dir=$(dirname "$0") 30 | else 31 | dir=$(pwd)/$(dirname "$0") 32 | fi 33 | 34 | cd $dir/.. 35 | workdir=$(pwd) 36 | 37 | #------------------------------------------------------ 38 | source tool/include 39 | 40 | pids=$(ps -ef | grep -w "$cmdline" | grep -v "grep" | awk '{print $2}') 41 | array=($pids) 42 | if [ "${#array[@]}" == "0" ]; then 43 | start 44 | fi 45 | 46 | if [[ "${enable_cron}" == "true" ]]; then 47 | add_cron 48 | fi 49 | 50 | #------------------------------------------------------ 51 | 52 | cd $curpath 53 | -------------------------------------------------------------------------------- /bootstrap/run_windows.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package bootstrap 19 | 20 | import ( 21 | "os" 22 | "os/signal" 23 | "syscall" 24 | 25 | "github.com/polarismesh/polaris/apiserver" 26 | "github.com/polarismesh/polaris/common/log" 27 | ) 28 | 29 | var ( 30 | winSignals = []os.Signal{ 31 | syscall.SIGINT, syscall.SIGTERM, 32 | syscall.SIGSEGV, 33 | } 34 | ch = make(chan os.Signal, 1) 35 | ) 36 | 37 | // WaitSignal 等待信号量或err chan 从而执行restart或平滑退出 38 | func WaitSignal(servers []apiserver.Apiserver, errCh chan error) { 39 | defer StopServers(servers) 40 | 41 | signal.Notify(ch, winSignals...) 42 | 43 | select { 44 | case s := <-ch: 45 | log.Infof("catch signal(%s), stop servers", s.String()) 46 | case err := <-errCh: 47 | log.Errorf("catch api server err: %s", err.Error()) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /store/test_export.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package store 19 | 20 | import ( 21 | "errors" 22 | "fmt" 23 | ) 24 | 25 | // TestGetStore 获取Store 26 | func TestGetStore() (Store, error) { 27 | name := config.Name 28 | if name == "" { 29 | return nil, errors.New("store name is empty") 30 | } 31 | 32 | s, ok := StoreSlots[name] 33 | if !ok { 34 | return nil, fmt.Errorf("store `%s` not found", name) 35 | } 36 | _ = s.Destroy() 37 | fmt.Printf("[Store][Info] current use store plugin : %s\n", s.Name()) 38 | 39 | if err := s.Initialize(config); err != nil { 40 | fmt.Printf("[ERROR] initialize store `%s` fail: %v", s.Name(), err) 41 | panic(err) 42 | } 43 | return s, nil 44 | } 45 | 46 | // TestInjectConfig just for test 47 | func TestInjectConfig(conf Config) { 48 | config = &conf 49 | } 50 | -------------------------------------------------------------------------------- /.github/workflows/golangci-lint.yml: -------------------------------------------------------------------------------- 1 | # Tencent is pleased to support the open source community by making Polaris available. 2 | # 3 | # Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 4 | # 5 | # Licensed under the BSD 3-Clause License (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://opensource.org/licenses/BSD-3-Clause 10 | # 11 | # Unless required by applicable law or agreed to in writing, software distributed 12 | # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | # CONDITIONS OF ANY KIND, either express or implied. See the License for the 14 | # specific language governing permissions and limitations under the License. 15 | 16 | name: golangci-lint 17 | on: 18 | push: 19 | branches: 20 | - main 21 | - release* 22 | pull_request: 23 | branches: 24 | - main 25 | - release* 26 | - feature/** 27 | 28 | jobs: 29 | golangci: 30 | strategy: 31 | matrix: 32 | go-version: [ "1.21.5" ] 33 | name: golangci-lint 34 | runs-on: ubuntu-latest 35 | steps: 36 | - uses: actions/setup-go@v3 37 | - uses: actions/checkout@v3 38 | - name: golangci-lint 39 | uses: golangci/golangci-lint-action@v3.6.0 40 | with: 41 | # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. 42 | version: latest 43 | args: --timeout=30m 44 | -------------------------------------------------------------------------------- /release/README.md: -------------------------------------------------------------------------------- 1 | # Installation Guide 2 | 3 | [English](./README.md) | [简体中文](./README-zh.md) 4 | 5 | README: 6 | 7 | - [How to install](#how-to-install) 8 | - [Standalone](#standalone) 9 | - [Cluster](#cluster) 10 | - [How to verify](#how-to-verify) 11 | 12 | ## How to install 13 | 14 | The release packages of standalone and cluster have been provided for Linux, Mac and Windows. 15 | 16 | - [Github Releases](https://github.com/polarismesh/polaris/releases) 17 | - [Gitee Releases](https://gitee.com/polarismesh/polaris/releases) 18 | 19 | ### Standalone 20 | 21 | **Linux** 22 | 23 | Download the package named `polaris-standalone-release-*.linux.*.zip`. 24 | 25 | ``` 26 | unzip polaris-standalone-release-*.linux.*.zip 27 | 28 | cd polaris-standalone-release-*.linux.* 29 | 30 | bash install.sh 31 | ``` 32 | 33 | **Mac** 34 | 35 | Download the package named `polaris-standalone-release-*.darwin.*.zip`. 36 | 37 | ``` 38 | unzip polaris-standalone-release-*.darwin.*.zip 39 | 40 | cd polaris-standalone-release-*.darwin.* 41 | 42 | bash install.sh 43 | ``` 44 | 45 | **Windows** 46 | 47 | Download the package named `polaris-standalone-release-*.windows.*.zip`. 48 | 49 | ``` 50 | unzip polaris-standalone-release-*.windows.*.zip 51 | 52 | cd polaris-standalone-release-*.windows.* 53 | 54 | install.bat 55 | ``` 56 | 57 | ### Cluster 58 | 59 | todo 60 | 61 | ## How to verify 62 | 63 | Run the command to verify the installation. 64 | 65 | ``` 66 | curl http://127.0.0.1:8090 67 | ``` 68 | 69 | If the response is "Polaris Server", the installation is successful. 70 | -------------------------------------------------------------------------------- /plugin/statis/prometheus/config_handle.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package prometheus 19 | 20 | import ( 21 | "github.com/polarismesh/polaris/common/metrics" 22 | ) 23 | 24 | func newConfigMetricHandle() *configMetricHandle { 25 | return &configMetricHandle{} 26 | } 27 | 28 | type configMetricHandle struct { 29 | } 30 | 31 | func (h *configMetricHandle) handle(ms []metrics.ConfigMetrics) { 32 | for i := range ms { 33 | m := ms[i] 34 | switch m.Type { 35 | case metrics.ConfigGroupMetric: 36 | metrics.GetConfigGroupTotal().With(m.Labels).Set(float64(m.Total)) 37 | case metrics.FileMetric: 38 | metrics.GetConfigFileTotal().With(m.Labels).Set(float64(m.Total)) 39 | case metrics.ReleaseFileMetric: 40 | metrics.GetReleaseConfigFileTotal().With(m.Labels).Set(float64(m.Total)) 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /common/model/gray.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package model 19 | 20 | import ( 21 | "fmt" 22 | "time" 23 | ) 24 | 25 | type GrayModule string 26 | 27 | const ( 28 | GrayModuleConfig GrayModule = "config" 29 | GrayModuleRatelimit GrayModule = "ratelimit" 30 | GrayModuleCircuitbreaker GrayModule = "circuitbreaker" 31 | GrayModuleRoute GrayModule = "route" 32 | ) 33 | 34 | // GrayRule 灰度资源 35 | type GrayResource struct { 36 | Name string 37 | MatchRule string 38 | CreateTime time.Time 39 | ModifyTime time.Time 40 | CreateBy string 41 | ModifyBy string 42 | Valid bool 43 | } 44 | 45 | // GetGrayConfigRealseKey 获取灰度资源key 46 | func GetGrayConfigRealseKey(release *SimpleConfigFileRelease) string { 47 | return fmt.Sprintf("%v@%v@%v@%v", GrayModuleConfig, release.Namespace, release.Group, release.FileName) 48 | } 49 | -------------------------------------------------------------------------------- /plugin/ratelimit/token/invoke.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package token 19 | 20 | import ( 21 | "github.com/polarismesh/polaris/plugin" 22 | ) 23 | 24 | // tokenBucket 实现Plugin接口 25 | type tokenBucket struct { 26 | config *Config 27 | limiters map[plugin.RatelimitType]limiter 28 | } 29 | 30 | // Name 实现Plugin接口,Name方法 31 | func (tb *tokenBucket) Name() string { 32 | return PluginName 33 | } 34 | 35 | // Initialize 实现Plugin接口,Initialize方法 36 | func (tb *tokenBucket) Initialize(c *plugin.ConfigEntry) error { 37 | return tb.initialize(c) 38 | } 39 | 40 | // Destroy 实现Plugin接口,Destroy方法 41 | func (tb *tokenBucket) Destroy() error { 42 | return nil 43 | } 44 | 45 | // Allow 限流接口实现 46 | func (tb *tokenBucket) Allow(typ plugin.RatelimitType, key string) bool { 47 | if !tb.config.Enable { 48 | return true 49 | } 50 | return tb.allow(typ, key) 51 | } 52 | -------------------------------------------------------------------------------- /plugin/healthchecker/leader/config.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package leader 19 | 20 | import ( 21 | "github.com/mitchellh/mapstructure" 22 | ) 23 | 24 | type Config struct { 25 | SoltNum int32 `json:"soltNum"` 26 | StreamNum int32 `json:"streamNum"` 27 | // only use for test 28 | checkLeader bool 29 | } 30 | 31 | func unmarshal(options map[string]interface{}) (*Config, error) { 32 | config := &Config{ 33 | SoltNum: DefaultSoltNum, 34 | StreamNum: int32(streamNum), 35 | } 36 | decodeConfig := &mapstructure.DecoderConfig{ 37 | DecodeHook: mapstructure.StringToTimeDurationHookFunc(), 38 | Result: config, 39 | } 40 | decoder, err := mapstructure.NewDecoder(decodeConfig) 41 | if err != nil { 42 | return nil, err 43 | } 44 | if err = decoder.Decode(options); err != nil { 45 | return nil, err 46 | } 47 | return config, nil 48 | } 49 | -------------------------------------------------------------------------------- /release/cluster/kubernetes/04-prometheus-config.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: polaris-prometheus-config 5 | namespace: polaris-system 6 | data: 7 | prometheus.yaml: |- 8 | # my global config 9 | global: 10 | scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. 11 | evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. 12 | # scrape_timeout is set to the global default (10s). 13 | 14 | # Alertmanager configuration 15 | alerting: 16 | alertmanagers: 17 | - static_configs: 18 | - targets: 19 | - 127.0.0.1:9093 20 | 21 | # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. 22 | rule_files: 23 | # - "first_rules.yml" 24 | # - "second_rules.yml" 25 | - "/data/prom_rules/prom-alarm-rules.yml" 26 | 27 | # A scrape configuration containing exactly one endpoint to scrape: 28 | # Here it's Prometheus itself. 29 | scrape_configs: 30 | # The job name is added as a label `job=` to any timeseries scraped from this config. 31 | - job_name: "prometheus" 32 | # metrics_path defaults to '/metrics' 33 | # scheme defaults to 'http'. 34 | static_configs: 35 | - targets: ["localhost:9090"] 36 | http_sd_configs: 37 | - url: http://polaris:8090/prometheus/v1/clients 38 | honor_labels: true 39 | - job_name: "push-metrics" 40 | static_configs: 41 | - targets: ["localhost:9091"] -------------------------------------------------------------------------------- /release/upgrade/circuitbreaker_rule_transform/go.sum: -------------------------------------------------------------------------------- 1 | github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= 2 | github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= 3 | github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= 4 | github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= 5 | github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= 6 | github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= 7 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 8 | github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= 9 | github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 10 | github.com/polarismesh/specification v1.1.1 h1:BxZ5p78g4kaoGZ6EPM1b+QT/QCI/nkR/1qlcAeKdtdA= 11 | github.com/polarismesh/specification v1.1.1/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= 12 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= 13 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 14 | google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= 15 | google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= 16 | google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= 17 | google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= 18 | -------------------------------------------------------------------------------- /test/integrate/grpc/heartbeat.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package grpc 19 | 20 | import ( 21 | "context" 22 | "fmt" 23 | "time" 24 | 25 | apiservice "github.com/polarismesh/specification/source/go/api/v1/service_manage" 26 | "google.golang.org/grpc/metadata" 27 | 28 | "github.com/polarismesh/polaris/common/utils" 29 | ) 30 | 31 | // Heartbeat 上报心跳 32 | func (c *Client) Heartbeat(instance *apiservice.Instance) error { 33 | fmt.Printf("\nheartbeat\n") 34 | 35 | md := metadata.Pairs("request-id", utils.NewUUID()) 36 | ctx := metadata.NewOutgoingContext(context.Background(), md) 37 | 38 | ctx, cancel := context.WithTimeout(ctx, time.Second) 39 | defer cancel() 40 | 41 | rsp, err := c.Worker.Heartbeat(ctx, instance) 42 | if err != nil { 43 | fmt.Printf("%v\n", err) 44 | return err 45 | } 46 | 47 | fmt.Printf("%v\n", rsp) 48 | 49 | return nil 50 | } 51 | -------------------------------------------------------------------------------- /common/utils/context.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package utils 19 | 20 | import "context" 21 | 22 | type ( 23 | // StringContext is a context key that carries a string. 24 | StringContext string 25 | // localhostCtx is a context key that carries localhost info. 26 | localhostCtx struct{} 27 | // ContextAPIServerSlot 28 | ContextAPIServerSlot struct{} 29 | // WatchTimeoutCtx . 30 | WatchTimeoutCtx struct{} 31 | ) 32 | 33 | // WithLocalhost 存储localhost 34 | func WithLocalhost(ctx context.Context, localhost string) context.Context { 35 | return context.WithValue(ctx, localhostCtx{}, localhost) 36 | } 37 | 38 | // ValueLocalhost 获取localhost 39 | func ValueLocalhost(ctx context.Context) string { 40 | if ctx == nil { 41 | return "" 42 | } 43 | 44 | value, ok := ctx.Value(localhostCtx{}).(string) 45 | if !ok { 46 | return "" 47 | } 48 | 49 | return value 50 | } 51 | -------------------------------------------------------------------------------- /release/conf/plugin/ratelimit/rule.yaml: -------------------------------------------------------------------------------- 1 | # IP -level current, global 2 | ip-limit: 3 | # Whether the system opens IP -level current limit 4 | open: false 5 | global: 6 | open: false 7 | # Maximum peak 8 | bucket: 300 9 | # The average number of requests per second of IP 10 | rate: 200 11 | # Number of IP of the maximum cache 12 | resource-cache-amount: 1024 13 | white-list: [127.0.0.1] 14 | instance-limit: 15 | open: false 16 | global: 17 | bucket: 200 18 | rate: 100 19 | resource-cache-amount: 1024 20 | # Interface-level ratelimit limit 21 | api-limit: 22 | # Whether to turn on the interface restriction and global switch, only for TRUE can it represent the flow restriction on the system.By default 23 | open: false 24 | rules: 25 | - name: store-read 26 | limit: 27 | # The global configuration of the interface, if in the API sub -item, is not configured, the interface will be limited according to Global 28 | open: false 29 | # The maximum value of token barrels 30 | bucket: 2000 31 | # The number of token generated per second 32 | rate: 1000 33 | - name: store-write 34 | limit: 35 | open: false 36 | bucket: 1000 37 | rate: 500 38 | apis: 39 | - name: "POST:/v1/naming/services" 40 | rule: store-write 41 | - name: "PUT:/v1/naming/services" 42 | rule: store-write 43 | - name: "POST:/v1/naming/services/delete" 44 | rule: store-write 45 | - name: "GET:/v1/naming/services" 46 | rule: store-read 47 | - name: "GET:/v1/naming/services/count" 48 | rule: store-read -------------------------------------------------------------------------------- /release/cluster/helm/templates/config-prometheus.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: polaris-prometheus-config 5 | namespace: {{ .Values.installation.namespace }} 6 | data: 7 | prometheus.yaml: |- 8 | # my global config 9 | global: 10 | scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. 11 | evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. 12 | # scrape_timeout is set to the global default (10s). 13 | 14 | # Alertmanager configuration 15 | alerting: 16 | alertmanagers: 17 | - static_configs: 18 | - targets: 19 | - 127.0.0.1:9093 20 | 21 | # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. 22 | rule_files: 23 | # - "first_rules.yml" 24 | # - "second_rules.yml" 25 | - "/data/prom_rules/prom-alarm-rules.yml" 26 | 27 | # A scrape configuration containing exactly one endpoint to scrape: 28 | # Here it's Prometheus itself. 29 | scrape_configs: 30 | # The job name is added as a label `job=` to any timeseries scraped from this config. 31 | - job_name: "prometheus" 32 | # metrics_path defaults to '/metrics' 33 | # scheme defaults to 'http'. 34 | static_configs: 35 | - targets: ["localhost:9090"] 36 | http_sd_configs: 37 | - url: http://polaris:8090/prometheus/v1/clients 38 | honor_labels: true 39 | - job_name: "push-metrics" 40 | static_configs: 41 | - targets: ["localhost:9091"] -------------------------------------------------------------------------------- /test/integrate/grpc/report_client.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package grpc 19 | 20 | import ( 21 | "context" 22 | "fmt" 23 | "time" 24 | 25 | apiservice "github.com/polarismesh/specification/source/go/api/v1/service_manage" 26 | "google.golang.org/grpc/metadata" 27 | 28 | "github.com/polarismesh/polaris/common/utils" 29 | ) 30 | 31 | // ReportClient 上报客户端信息 32 | func (c *Client) ReportClient(client *apiservice.Client) error { 33 | fmt.Printf("\nreport client\n") 34 | 35 | md := metadata.Pairs("request-id", utils.NewUUID()) 36 | ctx := metadata.NewOutgoingContext(context.Background(), md) 37 | 38 | ctx, cancel := context.WithTimeout(ctx, time.Second) 39 | defer cancel() 40 | 41 | rsp, err := c.Worker.ReportClient(ctx, client) 42 | if err != nil { 43 | fmt.Printf("%v\n", err) 44 | return err 45 | } 46 | 47 | fmt.Printf("%v\n", rsp) 48 | 49 | return nil 50 | } 51 | -------------------------------------------------------------------------------- /common/srand/scalable_rand_test.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package srand 19 | 20 | import ( 21 | "math/rand" 22 | "testing" 23 | ) 24 | 25 | func BenchmarkSingleCore(b *testing.B) { 26 | 27 | b.Run("scalable_rand-Intn()", func(b *testing.B) { 28 | for i := 0; i < b.N; i++ { 29 | _ = Intn(1000) 30 | } 31 | }) 32 | 33 | b.Run("math/rand-Intn()", func(b *testing.B) { 34 | for i := 0; i < b.N; i++ { 35 | _ = rand.Intn(1000) 36 | } 37 | }) 38 | 39 | } 40 | 41 | func BenchmarkMultipleCore(b *testing.B) { 42 | 43 | b.Run("scalable_rand-Intn()", func(b *testing.B) { 44 | b.RunParallel(func(pb *testing.PB) { 45 | for pb.Next() { 46 | _ = Intn(1000) 47 | } 48 | }) 49 | }) 50 | 51 | b.Run("math/rand-Intn()", func(b *testing.B) { 52 | b.RunParallel(func(pb *testing.PB) { 53 | for pb.Next() { 54 | _ = rand.Intn(1000) 55 | } 56 | }) 57 | }) 58 | 59 | } 60 | -------------------------------------------------------------------------------- /apiserver/eurekaserver/eureka_suit_test.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package eurekaserver 19 | 20 | import ( 21 | _ "github.com/polarismesh/polaris/plugin/cmdb/memory" 22 | _ "github.com/polarismesh/polaris/plugin/discoverevent/local" 23 | _ "github.com/polarismesh/polaris/plugin/healthchecker/memory" 24 | _ "github.com/polarismesh/polaris/plugin/healthchecker/redis" 25 | _ "github.com/polarismesh/polaris/plugin/history/logger" 26 | _ "github.com/polarismesh/polaris/plugin/password" 27 | _ "github.com/polarismesh/polaris/plugin/ratelimit/token" 28 | _ "github.com/polarismesh/polaris/plugin/statis/logger" 29 | _ "github.com/polarismesh/polaris/plugin/statis/prometheus" 30 | testsuit "github.com/polarismesh/polaris/test/suit" 31 | ) 32 | 33 | type EurekaTestSuit struct { 34 | testsuit.DiscoverTestSuit 35 | } 36 | 37 | func newEurekaTestSuit() *EurekaTestSuit { 38 | return &EurekaTestSuit{} 39 | } 40 | -------------------------------------------------------------------------------- /apiserver/nacosserver/v1/config/config_file_test.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Polaris available. 3 | * 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * https://opensource.org/licenses/BSD-3-Clause 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed 13 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations under the License. 16 | */ 17 | 18 | package config 19 | 20 | import ( 21 | "testing" 22 | 23 | "github.com/polarismesh/polaris/apiserver/nacosserver/model" 24 | ) 25 | 26 | func Test_md5ResultString(t *testing.T) { 27 | type args struct { 28 | items []*model.ConfigListenItem 29 | } 30 | tests := []struct { 31 | name string 32 | args args 33 | want string 34 | }{{ 35 | name: "case-0", 36 | args: args{ 37 | items: []*model.ConfigListenItem{ 38 | { 39 | Tenant: "test2", 40 | Group: "test1", 41 | DataId: "test0", 42 | }, 43 | }, 44 | }, 45 | want: "test0%02test1%02test2%01", 46 | }} 47 | for _, tt := range tests { 48 | t.Run(tt.name, func(t *testing.T) { 49 | if got := md5ResultString(tt.args.items); got != tt.want { 50 | t.Errorf("md5ResultString() = %v, want %v", got, tt.want) 51 | } 52 | }) 53 | } 54 | } 55 | --------------------------------------------------------------------------------