Compare commits
	
		
			51 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 9955afc90d | |||
| 12fd9c04f5 | |||
| 0579d5df86 | |||
| 64703bb6f3 | |||
| 1f916abc1d | |||
| 
						 | 
					3a953fbf61 | ||
| 
						 | 
					7949bb3f1f | ||
| 
						 | 
					b88480bc51 | ||
| b2b7e9b1a2 | |||
| 5cbaca0068 | |||
| 
						 | 
					c2ea781b28 | ||
| c1e2eda3e5 | |||
| 88a553d931 | |||
| b56bb7f834 | |||
| a08cbee842 | |||
| a8b6d67344 | |||
| 3f589b20c4 | |||
| 78571b68ab | |||
| e1f18b0a9b | |||
| 279853ccb5 | |||
| ec4f5f084f | |||
| 
						 | 
					a6707dcac4 | ||
| 088a00dc79 | |||
| 
						 | 
					fdc0017341 | ||
| 61fe743eef | |||
| 
						 | 
					2bd03c4496 | ||
| cf2a186f29 | |||
| 
						 | 
					84a28ff806 | ||
| 7d7d3566e3 | |||
| 
						 | 
					49bfe33435 | ||
| 620495eabb | |||
| 
						 | 
					f965485d01 | ||
| a5499d08fe | |||
| 
						 | 
					e431b6a7a6 | ||
| 8c5f186cdc | |||
| 
						 | 
					f0ac1b9e29 | ||
| 1e84dab453 | |||
| 
						 | 
					00a84da9e6 | ||
| 8b9d9c96d9 | |||
| 
						 | 
					f4a93ba605 | ||
| 153f4073b8 | |||
| 
						 | 
					40f1fe4732 | ||
| cd50cc5366 | |||
| 
						 | 
					5128671bd0 | ||
| e33004352b | |||
| b308e073a0 | |||
| a65561a85e | |||
| 
						 | 
					f5e7889daf | ||
| a167fd531e | |||
| ab247ef9c6 | |||
| 28ebe788da | 
							
								
								
									
										19
									
								
								.github/dependabot.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								.github/dependabot.yml
									
									
									
									
										vendored
									
									
								
							@@ -1,19 +0,0 @@
 | 
				
			|||||||
# To get started with Dependabot version updates, you'll need to specify which
 | 
					 | 
				
			||||||
# package ecosystems to update and where the package manifests are located.
 | 
					 | 
				
			||||||
# Please see the documentation for all configuration options:
 | 
					 | 
				
			||||||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
version: 2
 | 
					 | 
				
			||||||
updates:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  # Maintain dependencies for GitHub Actions
 | 
					 | 
				
			||||||
  - package-ecosystem: "github-actions"
 | 
					 | 
				
			||||||
    directory: "/"
 | 
					 | 
				
			||||||
    schedule:
 | 
					 | 
				
			||||||
      interval: "daily"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  # Maintain dependencies for Golang
 | 
					 | 
				
			||||||
  - package-ecosystem: "gomod"
 | 
					 | 
				
			||||||
    directory: "/"
 | 
					 | 
				
			||||||
    schedule:
 | 
					 | 
				
			||||||
      interval: "daily"
 | 
					 | 
				
			||||||
							
								
								
									
										46
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										46
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							@@ -1,46 +0,0 @@
 | 
				
			|||||||
name: build
 | 
					 | 
				
			||||||
on:
 | 
					 | 
				
			||||||
 push:
 | 
					 | 
				
			||||||
    branches:
 | 
					 | 
				
			||||||
    - master
 | 
					 | 
				
			||||||
jobs:
 | 
					 | 
				
			||||||
  test:
 | 
					 | 
				
			||||||
    name: test
 | 
					 | 
				
			||||||
    runs-on: ubuntu-latest
 | 
					 | 
				
			||||||
    steps:
 | 
					 | 
				
			||||||
    - name: setup
 | 
					 | 
				
			||||||
      uses: actions/setup-go@v2
 | 
					 | 
				
			||||||
      with:
 | 
					 | 
				
			||||||
        go-version: 1.16
 | 
					 | 
				
			||||||
    - name: checkout
 | 
					 | 
				
			||||||
      uses: actions/checkout@v2
 | 
					 | 
				
			||||||
    - name: cache
 | 
					 | 
				
			||||||
      uses: actions/cache@v2
 | 
					 | 
				
			||||||
      with:
 | 
					 | 
				
			||||||
        path: ~/go/pkg/mod
 | 
					 | 
				
			||||||
        key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
 | 
					 | 
				
			||||||
        restore-keys: ${{ runner.os }}-go-
 | 
					 | 
				
			||||||
    - name: deps
 | 
					 | 
				
			||||||
      run: go get -v -t -d ./...
 | 
					 | 
				
			||||||
    - name: test
 | 
					 | 
				
			||||||
      env:
 | 
					 | 
				
			||||||
        INTEGRATION_TESTS: yes
 | 
					 | 
				
			||||||
      run: go test -mod readonly -v ./...
 | 
					 | 
				
			||||||
  lint:
 | 
					 | 
				
			||||||
    name: lint
 | 
					 | 
				
			||||||
    runs-on: ubuntu-latest
 | 
					 | 
				
			||||||
    steps:
 | 
					 | 
				
			||||||
      - name: checkout
 | 
					 | 
				
			||||||
        uses: actions/checkout@v2
 | 
					 | 
				
			||||||
      - name: lint
 | 
					 | 
				
			||||||
        uses: golangci/golangci-lint-action@v2
 | 
					 | 
				
			||||||
        continue-on-error: true
 | 
					 | 
				
			||||||
        with:
 | 
					 | 
				
			||||||
          # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
 | 
					 | 
				
			||||||
          version: v1.30
 | 
					 | 
				
			||||||
          # Optional: working directory, useful for monorepos
 | 
					 | 
				
			||||||
          # working-directory: somedir
 | 
					 | 
				
			||||||
          # Optional: golangci-lint command line arguments.
 | 
					 | 
				
			||||||
          # args: --issues-exit-code=0
 | 
					 | 
				
			||||||
          # Optional: show only new issues if it's a pull request. The default value is `false`.
 | 
					 | 
				
			||||||
          # only-new-issues: true
 | 
					 | 
				
			||||||
							
								
								
									
										75
									
								
								.github/workflows/codeql-analysis.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										75
									
								
								.github/workflows/codeql-analysis.yml
									
									
									
									
										vendored
									
									
								
							@@ -1,75 +0,0 @@
 | 
				
			|||||||
# For most projects, this workflow file will not need changing; you simply need
 | 
					 | 
				
			||||||
# to commit it to your repository.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# You may wish to alter this file to override the set of languages analyzed,
 | 
					 | 
				
			||||||
# or to provide custom queries or build logic.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# ******** NOTE ********
 | 
					 | 
				
			||||||
# We have attempted to detect the languages in your repository. Please check
 | 
					 | 
				
			||||||
# the `language` matrix defined below to confirm you have the correct set of
 | 
					 | 
				
			||||||
# supported CodeQL languages.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
name: "CodeQL"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
on:
 | 
					 | 
				
			||||||
  workflow_run:
 | 
					 | 
				
			||||||
    workflows: ["prbuild"]
 | 
					 | 
				
			||||||
    types:
 | 
					 | 
				
			||||||
      - completed
 | 
					 | 
				
			||||||
  push:
 | 
					 | 
				
			||||||
    branches: [ master ]
 | 
					 | 
				
			||||||
  pull_request:
 | 
					 | 
				
			||||||
    # The branches below must be a subset of the branches above
 | 
					 | 
				
			||||||
    branches: [ master ]
 | 
					 | 
				
			||||||
  schedule:
 | 
					 | 
				
			||||||
    - cron: '34 1 * * 0'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
jobs:
 | 
					 | 
				
			||||||
  analyze:
 | 
					 | 
				
			||||||
    name: Analyze
 | 
					 | 
				
			||||||
    runs-on: ubuntu-latest
 | 
					 | 
				
			||||||
    permissions:
 | 
					 | 
				
			||||||
      actions: read
 | 
					 | 
				
			||||||
      contents: read
 | 
					 | 
				
			||||||
      security-events: write
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    strategy:
 | 
					 | 
				
			||||||
      fail-fast: false
 | 
					 | 
				
			||||||
      matrix:
 | 
					 | 
				
			||||||
        language: [ 'go' ]
 | 
					 | 
				
			||||||
        # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
 | 
					 | 
				
			||||||
        # Learn more:
 | 
					 | 
				
			||||||
        # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    steps:
 | 
					 | 
				
			||||||
    - name: Checkout repository
 | 
					 | 
				
			||||||
      uses: actions/checkout@v2
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Initializes the CodeQL tools for scanning.
 | 
					 | 
				
			||||||
    - name: Initialize CodeQL
 | 
					 | 
				
			||||||
      uses: github/codeql-action/init@v1
 | 
					 | 
				
			||||||
      with:
 | 
					 | 
				
			||||||
        languages: ${{ matrix.language }}
 | 
					 | 
				
			||||||
        # If you wish to specify custom queries, you can do so here or in a config file.
 | 
					 | 
				
			||||||
        # By default, queries listed here will override any specified in a config file.
 | 
					 | 
				
			||||||
        # Prefix the list here with "+" to use these queries and those in the config file.
 | 
					 | 
				
			||||||
        # queries: ./path/to/local/query, your-org/your-repo/queries@main
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Autobuild attempts to build any compiled languages  (C/C++, C#, or Java).
 | 
					 | 
				
			||||||
    # If this step fails, then you should remove it and run the build manually (see below)
 | 
					 | 
				
			||||||
    - name: Autobuild
 | 
					 | 
				
			||||||
      uses: github/codeql-action/autobuild@v1
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    # ℹ️ Command-line programs to run using the OS shell.
 | 
					 | 
				
			||||||
    # 📚 https://git.io/JvXDl
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
 | 
					 | 
				
			||||||
    #    and modify them (or add more) to build your code if your project
 | 
					 | 
				
			||||||
    #    uses a compiled language
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    #- run: |
 | 
					 | 
				
			||||||
    #   make bootstrap
 | 
					 | 
				
			||||||
    #   make release
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    - name: Perform CodeQL Analysis
 | 
					 | 
				
			||||||
      uses: github/codeql-action/analyze@v1
 | 
					 | 
				
			||||||
							
								
								
									
										66
									
								
								.github/workflows/dependabot-automerge.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										66
									
								
								.github/workflows/dependabot-automerge.yml
									
									
									
									
										vendored
									
									
								
							@@ -1,66 +0,0 @@
 | 
				
			|||||||
name: "prautomerge"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
on:
 | 
					 | 
				
			||||||
  workflow_run:
 | 
					 | 
				
			||||||
    workflows: ["prbuild"]
 | 
					 | 
				
			||||||
    types:
 | 
					 | 
				
			||||||
      - completed
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
permissions:
 | 
					 | 
				
			||||||
  contents: write
 | 
					 | 
				
			||||||
  pull-requests: write
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
jobs:
 | 
					 | 
				
			||||||
  Dependabot-Automerge:
 | 
					 | 
				
			||||||
    runs-on: ubuntu-latest
 | 
					 | 
				
			||||||
    # Contains workaround to execute if dependabot updates the PR by checking for the base branch in the linked PR
 | 
					 | 
				
			||||||
    # The the github.event.workflow_run.event value is 'push' and not 'pull_request'
 | 
					 | 
				
			||||||
    # dont work with multiple workflows when last returns success
 | 
					 | 
				
			||||||
    if: >-
 | 
					 | 
				
			||||||
      github.event.workflow_run.conclusion == 'success'
 | 
					 | 
				
			||||||
      && github.actor == 'dependabot[bot]'
 | 
					 | 
				
			||||||
      && github.event.sender.login == 'dependabot[bot]'
 | 
					 | 
				
			||||||
      && github.event.sender.type == 'Bot'
 | 
					 | 
				
			||||||
      && (github.event.workflow_run.event == 'pull_request'
 | 
					 | 
				
			||||||
          || (github.event.workflow_run.event == 'push' && github.event.workflow_run.pull_requests[0].base.ref == github.event.repository.default_branch ))
 | 
					 | 
				
			||||||
    steps:
 | 
					 | 
				
			||||||
      - name: Approve Changes and Merge changes if label 'dependencies' is set
 | 
					 | 
				
			||||||
        uses: actions/github-script@v5
 | 
					 | 
				
			||||||
        with:
 | 
					 | 
				
			||||||
          github-token: ${{ secrets.GITHUB_TOKEN }}
 | 
					 | 
				
			||||||
          script: |
 | 
					 | 
				
			||||||
            console.log(context.payload.workflow_run);
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            var labelNames = await github.paginate(
 | 
					 | 
				
			||||||
              github.issues.listLabelsOnIssue,
 | 
					 | 
				
			||||||
              {
 | 
					 | 
				
			||||||
                repo: context.repo.repo,
 | 
					 | 
				
			||||||
                owner: context.repo.owner,
 | 
					 | 
				
			||||||
                issue_number: context.payload.workflow_run.pull_requests[0].number,
 | 
					 | 
				
			||||||
              },
 | 
					 | 
				
			||||||
              (response) => response.data.map(
 | 
					 | 
				
			||||||
                (label) => label.name
 | 
					 | 
				
			||||||
              )
 | 
					 | 
				
			||||||
            );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            console.log(labelNames);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (labelNames.includes('dependencies')) {
 | 
					 | 
				
			||||||
              console.log('Found label');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
              await github.pulls.createReview({
 | 
					 | 
				
			||||||
                repo: context.repo.repo,
 | 
					 | 
				
			||||||
                owner: context.repo.owner,
 | 
					 | 
				
			||||||
                pull_number: context.payload.workflow_run.pull_requests[0].number,
 | 
					 | 
				
			||||||
                event: 'APPROVE'
 | 
					 | 
				
			||||||
              });
 | 
					 | 
				
			||||||
              console.log('Approved PR');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
              await github.pulls.merge({
 | 
					 | 
				
			||||||
                repo: context.repo.repo,
 | 
					 | 
				
			||||||
                owner: context.repo.owner,
 | 
					 | 
				
			||||||
                pull_number: context.payload.workflow_run.pull_requests[0].number,
 | 
					 | 
				
			||||||
              });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
              console.log('Merged PR');
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
							
								
								
									
										53
									
								
								.github/workflows/job_coverage.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								.github/workflows/job_coverage.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,53 @@
 | 
				
			|||||||
 | 
					name: coverage
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					on:
 | 
				
			||||||
 | 
					  push:
 | 
				
			||||||
 | 
					    branches: [ main, v3, v4 ]
 | 
				
			||||||
 | 
					    paths-ignore:
 | 
				
			||||||
 | 
					      - '.github/**'
 | 
				
			||||||
 | 
					      - '.gitea/**'
 | 
				
			||||||
 | 
					  pull_request:
 | 
				
			||||||
 | 
					    branches: [ main, v3, v4 ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					jobs:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  build:
 | 
				
			||||||
 | 
					    if: github.server_url != 'https://github.com'
 | 
				
			||||||
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
 | 
					    steps:
 | 
				
			||||||
 | 
					    - name: checkout code
 | 
				
			||||||
 | 
					      uses: actions/checkout@v4
 | 
				
			||||||
 | 
					      with:
 | 
				
			||||||
 | 
					        filter: 'blob:none'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    - name: setup go
 | 
				
			||||||
 | 
					      uses: actions/setup-go@v5
 | 
				
			||||||
 | 
					      with:
 | 
				
			||||||
 | 
					        cache-dependency-path: "**/*.sum"
 | 
				
			||||||
 | 
					        go-version: 'stable'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    - name: test coverage
 | 
				
			||||||
 | 
					      run: |
 | 
				
			||||||
 | 
					        go test -v -cover ./... -covermode=count -coverprofile coverage.out -coverpkg ./...
 | 
				
			||||||
 | 
					        go tool cover -func coverage.out -o coverage.out
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    - name: coverage badge
 | 
				
			||||||
 | 
					      uses: tj-actions/coverage-badge-go@v3
 | 
				
			||||||
 | 
					      with:
 | 
				
			||||||
 | 
					        green: 80
 | 
				
			||||||
 | 
					        filename: coverage.out
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    - uses: stefanzweifel/git-auto-commit-action@v4
 | 
				
			||||||
 | 
					      name: autocommit
 | 
				
			||||||
 | 
					      with:
 | 
				
			||||||
 | 
					        commit_message: Apply Code Coverage Badge
 | 
				
			||||||
 | 
					        skip_fetch: false
 | 
				
			||||||
 | 
					        skip_checkout: false
 | 
				
			||||||
 | 
					        file_pattern: ./README.md
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    - name: push
 | 
				
			||||||
 | 
					      if: steps.auto-commit-action.outputs.changes_detected == 'true'
 | 
				
			||||||
 | 
					      uses: ad-m/github-push-action@master
 | 
				
			||||||
 | 
					      with:
 | 
				
			||||||
 | 
					        github_token: ${{ github.token }}
 | 
				
			||||||
 | 
					        branch: ${{ github.ref }}
 | 
				
			||||||
							
								
								
									
										29
									
								
								.github/workflows/job_lint.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								.github/workflows/job_lint.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,29 @@
 | 
				
			|||||||
 | 
					name: lint
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					on:
 | 
				
			||||||
 | 
					  pull_request:
 | 
				
			||||||
 | 
					    types: [opened, reopened, synchronize]
 | 
				
			||||||
 | 
					    branches: [ master, v3, v4 ]
 | 
				
			||||||
 | 
					    paths-ignore:
 | 
				
			||||||
 | 
					      - '.github/**'
 | 
				
			||||||
 | 
					      - '.gitea/**'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					jobs:
 | 
				
			||||||
 | 
					  lint:
 | 
				
			||||||
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
 | 
					    steps:
 | 
				
			||||||
 | 
					    - name: checkout code
 | 
				
			||||||
 | 
					      uses: actions/checkout@v4
 | 
				
			||||||
 | 
					      with:
 | 
				
			||||||
 | 
					        filter: 'blob:none'
 | 
				
			||||||
 | 
					    - name: setup go
 | 
				
			||||||
 | 
					      uses: actions/setup-go@v5
 | 
				
			||||||
 | 
					      with:
 | 
				
			||||||
 | 
					        cache-dependency-path: "**/*.sum"
 | 
				
			||||||
 | 
					        go-version: 'stable'
 | 
				
			||||||
 | 
					    - name: setup deps
 | 
				
			||||||
 | 
					      run: go get -v ./...
 | 
				
			||||||
 | 
					    - name: run lint
 | 
				
			||||||
 | 
					      uses: golangci/golangci-lint-action@v6
 | 
				
			||||||
 | 
					      with:
 | 
				
			||||||
 | 
					        version: 'latest'
 | 
				
			||||||
							
								
								
									
										94
									
								
								.github/workflows/job_sync.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								.github/workflows/job_sync.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,94 @@
 | 
				
			|||||||
 | 
					name: sync
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					on:
 | 
				
			||||||
 | 
					  schedule:
 | 
				
			||||||
 | 
					    - cron: '*/5 * * * *'
 | 
				
			||||||
 | 
					  # Allows you to run this workflow manually from the Actions tab
 | 
				
			||||||
 | 
					  workflow_dispatch:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					jobs:
 | 
				
			||||||
 | 
					  sync:
 | 
				
			||||||
 | 
					    if: github.server_url != 'https://github.com'
 | 
				
			||||||
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
 | 
					    steps:
 | 
				
			||||||
 | 
					    - name: init
 | 
				
			||||||
 | 
					      run: |
 | 
				
			||||||
 | 
					        git config --global user.email "vtolstov <vtolstov@users.noreply.github.com>"
 | 
				
			||||||
 | 
					        git config --global user.name "github-actions[bot]"
 | 
				
			||||||
 | 
					        echo "machine git.unistack.org login vtolstov password ${{ secrets.TOKEN_GITEA }}" >> /root/.netrc
 | 
				
			||||||
 | 
					        echo "machine github.com login vtolstov password ${{ secrets.TOKEN_GITHUB }}" >> /root/.netrc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    - name: check master
 | 
				
			||||||
 | 
					      id: check_master
 | 
				
			||||||
 | 
					      run: |
 | 
				
			||||||
 | 
					        src_hash=$(git ls-remote https://github.com/${GITHUB_REPOSITORY} refs/heads/master | cut -f1)
 | 
				
			||||||
 | 
					        dst_hash=$(git ls-remote ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} refs/heads/master | cut -f1)
 | 
				
			||||||
 | 
					        echo "src_hash=$src_hash"
 | 
				
			||||||
 | 
					        echo "dst_hash=$dst_hash"
 | 
				
			||||||
 | 
					        if [ "$src_hash" != "$dst_hash" ]; then
 | 
				
			||||||
 | 
					          echo "sync_needed=true" >> $GITHUB_OUTPUT
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					          echo "sync_needed=false" >> $GITHUB_OUTPUT
 | 
				
			||||||
 | 
					        fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    - name: sync master
 | 
				
			||||||
 | 
					      if: steps.check_master.outputs.sync_needed == 'true'
 | 
				
			||||||
 | 
					      run: |
 | 
				
			||||||
 | 
					        git clone --filter=blob:none --filter=tree:0 --branch master --single-branch ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} repo
 | 
				
			||||||
 | 
					        cd repo
 | 
				
			||||||
 | 
					        git remote add --no-tags --fetch --track master upstream https://github.com/${GITHUB_REPOSITORY}
 | 
				
			||||||
 | 
					        git pull --rebase upstream master
 | 
				
			||||||
 | 
					        git push upstream master --progress
 | 
				
			||||||
 | 
					        git push origin master --progress
 | 
				
			||||||
 | 
					        cd ../
 | 
				
			||||||
 | 
					        rm -rf repo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    - name: check v3
 | 
				
			||||||
 | 
					      id: check_v3
 | 
				
			||||||
 | 
					      run: |
 | 
				
			||||||
 | 
					        src_hash=$(git ls-remote https://github.com/${GITHUB_REPOSITORY} refs/heads/v3 | cut -f1)
 | 
				
			||||||
 | 
					        dst_hash=$(git ls-remote ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} refs/heads/v3 | cut -f1)
 | 
				
			||||||
 | 
					        echo "src_hash=$src_hash"
 | 
				
			||||||
 | 
					        echo "dst_hash=$dst_hash"
 | 
				
			||||||
 | 
					        if [ "$src_hash" != "$dst_hash" ]; then
 | 
				
			||||||
 | 
					          echo "sync_needed=true" >> $GITHUB_OUTPUT
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					          echo "sync_needed=false" >> $GITHUB_OUTPUT
 | 
				
			||||||
 | 
					        fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    - name: sync v3
 | 
				
			||||||
 | 
					      if: steps.check_v3.outputs.sync_needed == 'true'
 | 
				
			||||||
 | 
					      run: |
 | 
				
			||||||
 | 
					        git clone --filter=blob:none --filter=tree:0 --branch v3 --single-branch ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} repo
 | 
				
			||||||
 | 
					        cd repo
 | 
				
			||||||
 | 
					        git remote add --no-tags --fetch --track v3 upstream https://github.com/${GITHUB_REPOSITORY}
 | 
				
			||||||
 | 
					        git pull --rebase upstream v3
 | 
				
			||||||
 | 
					        git push upstream v3 --progress
 | 
				
			||||||
 | 
					        git push origin v3 --progress
 | 
				
			||||||
 | 
					        cd ../
 | 
				
			||||||
 | 
					        rm -rf repo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    - name: check v4
 | 
				
			||||||
 | 
					      id: check_v4
 | 
				
			||||||
 | 
					      run: |
 | 
				
			||||||
 | 
					        src_hash=$(git ls-remote https://github.com/${GITHUB_REPOSITORY} refs/heads/v4 | cut -f1)
 | 
				
			||||||
 | 
					        dst_hash=$(git ls-remote ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} refs/heads/v4 | cut -f1)
 | 
				
			||||||
 | 
					        echo "src_hash=$src_hash"
 | 
				
			||||||
 | 
					        echo "dst_hash=$dst_hash"
 | 
				
			||||||
 | 
					        if [ "$src_hash" != "$dst_hash" ]; then
 | 
				
			||||||
 | 
					          echo "sync_needed=true" >> $GITHUB_OUTPUT
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					          echo "sync_needed=false" >> $GITHUB_OUTPUT
 | 
				
			||||||
 | 
					        fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    - name: sync v4
 | 
				
			||||||
 | 
					      if: steps.check_v4.outputs.sync_needed == 'true'
 | 
				
			||||||
 | 
					      run: |
 | 
				
			||||||
 | 
					        git clone --filter=blob:none --filter=tree:0 --branch v4 --single-branch ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} repo
 | 
				
			||||||
 | 
					        cd repo
 | 
				
			||||||
 | 
					        git remote add --no-tags --fetch --track v4 upstream https://github.com/${GITHUB_REPOSITORY}
 | 
				
			||||||
 | 
					        git pull --rebase upstream v4
 | 
				
			||||||
 | 
					        git push upstream v4 --progress
 | 
				
			||||||
 | 
					        git push origin v4 --progress
 | 
				
			||||||
 | 
					        cd ../
 | 
				
			||||||
 | 
					        rm -rf repo
 | 
				
			||||||
							
								
								
									
										31
									
								
								.github/workflows/job_test.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								.github/workflows/job_test.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
				
			|||||||
 | 
					name: test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					on:
 | 
				
			||||||
 | 
					  pull_request:
 | 
				
			||||||
 | 
					    types: [opened, reopened, synchronize]
 | 
				
			||||||
 | 
					    branches: [ master, v3, v4 ]
 | 
				
			||||||
 | 
					  push:
 | 
				
			||||||
 | 
					    branches: [ master, v3, v4 ]
 | 
				
			||||||
 | 
					    paths-ignore:
 | 
				
			||||||
 | 
					      - '.github/**'
 | 
				
			||||||
 | 
					      - '.gitea/**'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					jobs:
 | 
				
			||||||
 | 
					  test:
 | 
				
			||||||
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
 | 
					    steps:
 | 
				
			||||||
 | 
					    - name: checkout code
 | 
				
			||||||
 | 
					      uses: actions/checkout@v4
 | 
				
			||||||
 | 
					      with:
 | 
				
			||||||
 | 
					        filter: 'blob:none'
 | 
				
			||||||
 | 
					    - name: setup go
 | 
				
			||||||
 | 
					      uses: actions/setup-go@v5
 | 
				
			||||||
 | 
					      with:
 | 
				
			||||||
 | 
					        cache-dependency-path: "**/*.sum"
 | 
				
			||||||
 | 
					        go-version: 'stable'
 | 
				
			||||||
 | 
					    - name: setup deps
 | 
				
			||||||
 | 
					      run: go get -v ./...
 | 
				
			||||||
 | 
					    - name: run test
 | 
				
			||||||
 | 
					      env:
 | 
				
			||||||
 | 
					        INTEGRATION_TESTS: yes
 | 
				
			||||||
 | 
					      run: go test -mod readonly -v ./...
 | 
				
			||||||
							
								
								
									
										50
									
								
								.github/workflows/job_tests.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								.github/workflows/job_tests.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,50 @@
 | 
				
			|||||||
 | 
					name: test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					on:
 | 
				
			||||||
 | 
					  pull_request:
 | 
				
			||||||
 | 
					    types: [opened, reopened, synchronize]
 | 
				
			||||||
 | 
					    branches: [ master, v3, v4 ]
 | 
				
			||||||
 | 
					  push:
 | 
				
			||||||
 | 
					    branches: [ master, v3, v4 ]
 | 
				
			||||||
 | 
					    paths-ignore:
 | 
				
			||||||
 | 
					      - '.github/**'
 | 
				
			||||||
 | 
					      - '.gitea/**'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					jobs:
 | 
				
			||||||
 | 
					  test:
 | 
				
			||||||
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
 | 
					    steps:
 | 
				
			||||||
 | 
					    - name: checkout code
 | 
				
			||||||
 | 
					      uses: actions/checkout@v4
 | 
				
			||||||
 | 
					      with:
 | 
				
			||||||
 | 
					        filter: 'blob:none'
 | 
				
			||||||
 | 
					    - name: checkout tests
 | 
				
			||||||
 | 
					      uses: actions/checkout@v4
 | 
				
			||||||
 | 
					      with:
 | 
				
			||||||
 | 
					        ref: master
 | 
				
			||||||
 | 
					        filter: 'blob:none'
 | 
				
			||||||
 | 
					        repository: unistack-org/micro-tests
 | 
				
			||||||
 | 
					        path: micro-tests
 | 
				
			||||||
 | 
					    - name: setup go
 | 
				
			||||||
 | 
					      uses: actions/setup-go@v5
 | 
				
			||||||
 | 
					      with:
 | 
				
			||||||
 | 
					        cache-dependency-path: "**/*.sum"
 | 
				
			||||||
 | 
					        go-version: 'stable'
 | 
				
			||||||
 | 
					    - name: setup go work
 | 
				
			||||||
 | 
					      env:
 | 
				
			||||||
 | 
					        GOWORK: ${{ github.workspace }}/go.work
 | 
				
			||||||
 | 
					      run: |
 | 
				
			||||||
 | 
					        go work init
 | 
				
			||||||
 | 
					        go work use .
 | 
				
			||||||
 | 
					        go work use micro-tests
 | 
				
			||||||
 | 
					    - name: setup deps
 | 
				
			||||||
 | 
					      env:
 | 
				
			||||||
 | 
					        GOWORK: ${{ github.workspace }}/go.work
 | 
				
			||||||
 | 
					      run: go get -v ./...
 | 
				
			||||||
 | 
					    - name: run tests
 | 
				
			||||||
 | 
					      env:
 | 
				
			||||||
 | 
					        INTEGRATION_TESTS: yes
 | 
				
			||||||
 | 
					        GOWORK: ${{ github.workspace }}/go.work
 | 
				
			||||||
 | 
					      run: |
 | 
				
			||||||
 | 
					        cd micro-tests
 | 
				
			||||||
 | 
					        go test -mod readonly -v ./... || true
 | 
				
			||||||
							
								
								
									
										46
									
								
								.github/workflows/pr.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										46
									
								
								.github/workflows/pr.yml
									
									
									
									
										vendored
									
									
								
							@@ -1,46 +0,0 @@
 | 
				
			|||||||
name: prbuild
 | 
					 | 
				
			||||||
on:
 | 
					 | 
				
			||||||
  pull_request:
 | 
					 | 
				
			||||||
    branches:
 | 
					 | 
				
			||||||
    - master
 | 
					 | 
				
			||||||
jobs:
 | 
					 | 
				
			||||||
  test:
 | 
					 | 
				
			||||||
    name: test
 | 
					 | 
				
			||||||
    runs-on: ubuntu-latest
 | 
					 | 
				
			||||||
    steps:
 | 
					 | 
				
			||||||
    - name: setup
 | 
					 | 
				
			||||||
      uses: actions/setup-go@v2
 | 
					 | 
				
			||||||
      with:
 | 
					 | 
				
			||||||
        go-version: 1.16
 | 
					 | 
				
			||||||
    - name: checkout
 | 
					 | 
				
			||||||
      uses: actions/checkout@v2
 | 
					 | 
				
			||||||
    - name: cache
 | 
					 | 
				
			||||||
      uses: actions/cache@v2
 | 
					 | 
				
			||||||
      with:
 | 
					 | 
				
			||||||
        path: ~/go/pkg/mod
 | 
					 | 
				
			||||||
        key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
 | 
					 | 
				
			||||||
        restore-keys: ${{ runner.os }}-go-
 | 
					 | 
				
			||||||
    - name: deps
 | 
					 | 
				
			||||||
      run: go get -v -t -d ./...
 | 
					 | 
				
			||||||
    - name: test
 | 
					 | 
				
			||||||
      env:
 | 
					 | 
				
			||||||
        INTEGRATION_TESTS: yes
 | 
					 | 
				
			||||||
      run: go test -mod readonly -v ./...
 | 
					 | 
				
			||||||
  lint:
 | 
					 | 
				
			||||||
    name: lint
 | 
					 | 
				
			||||||
    runs-on: ubuntu-latest
 | 
					 | 
				
			||||||
    steps:
 | 
					 | 
				
			||||||
      - name: checkout
 | 
					 | 
				
			||||||
        uses: actions/checkout@v2
 | 
					 | 
				
			||||||
      - name: lint
 | 
					 | 
				
			||||||
        uses: golangci/golangci-lint-action@v2
 | 
					 | 
				
			||||||
        continue-on-error: true
 | 
					 | 
				
			||||||
        with:
 | 
					 | 
				
			||||||
          # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
 | 
					 | 
				
			||||||
          version: v1.30
 | 
					 | 
				
			||||||
          # Optional: working directory, useful for monorepos
 | 
					 | 
				
			||||||
          # working-directory: somedir
 | 
					 | 
				
			||||||
          # Optional: golangci-lint command line arguments.
 | 
					 | 
				
			||||||
          # args: --issues-exit-code=0
 | 
					 | 
				
			||||||
          # Optional: show only new issues if it's a pull request. The default value is `false`.
 | 
					 | 
				
			||||||
          # only-new-issues: true
 | 
					 | 
				
			||||||
							
								
								
									
										5
									
								
								.golangci.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								.golangci.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					run:
 | 
				
			||||||
 | 
					  concurrency: 8
 | 
				
			||||||
 | 
					  timeout: 5m
 | 
				
			||||||
 | 
					  issues-exit-code: 1
 | 
				
			||||||
 | 
					  tests: true
 | 
				
			||||||
@@ -1,4 +1,5 @@
 | 
				
			|||||||
# VictoriaMetrics
 | 
					# VictoriaMetrics
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Wrappers are a form of middleware that can be used with go-micro services. They can wrap both the Client and Server handlers. 
 | 
					Wrappers are a form of middleware that can be used with go-micro services. They can wrap both the Client and Server handlers. 
 | 
				
			||||||
This plugin implements the HandlerWrapper interface to provide automatic prometheus metric handling
 | 
					This plugin implements the HandlerWrapper interface to provide automatic prometheus metric handling
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										23
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								go.mod
									
									
									
									
									
								
							@@ -1,8 +1,23 @@
 | 
				
			|||||||
module go.unistack.org/micro-meter-victoriametrics/v3
 | 
					module go.unistack.org/micro-meter-victoriametrics/v4
 | 
				
			||||||
 | 
					
 | 
				
			||||||
go 1.16
 | 
					go 1.24.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					toolchain go1.24.4
 | 
				
			||||||
 | 
					
 | 
				
			||||||
require (
 | 
					require (
 | 
				
			||||||
	github.com/VictoriaMetrics/metrics v1.18.0
 | 
						github.com/VictoriaMetrics/metrics v1.40.2
 | 
				
			||||||
	go.unistack.org/micro/v3 v3.8.0
 | 
						go.unistack.org/micro/v4 v4.1.22
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					require (
 | 
				
			||||||
 | 
						github.com/google/uuid v1.6.0 // indirect
 | 
				
			||||||
 | 
						github.com/matoous/go-nanoid v1.5.1 // indirect
 | 
				
			||||||
 | 
						github.com/spf13/cast v1.8.0 // indirect
 | 
				
			||||||
 | 
						github.com/valyala/fastrand v1.1.0 // indirect
 | 
				
			||||||
 | 
						github.com/valyala/histogram v1.2.0 // indirect
 | 
				
			||||||
 | 
						go.unistack.org/micro-proto/v4 v4.1.0 // indirect
 | 
				
			||||||
 | 
						golang.org/x/sys v0.37.0 // indirect
 | 
				
			||||||
 | 
						google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect
 | 
				
			||||||
 | 
						google.golang.org/grpc v1.72.0 // indirect
 | 
				
			||||||
 | 
						google.golang.org/protobuf v1.36.6 // indirect
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										73
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										73
									
								
								go.sum
									
									
									
									
									
								
							@@ -1,33 +1,48 @@
 | 
				
			|||||||
github.com/VictoriaMetrics/metrics v1.18.0 h1:vov5NxDHRSXFbdiH4dYLYEjKLoAXXSQ7hcnG8TSD9JQ=
 | 
					github.com/VictoriaMetrics/metrics v1.40.2 h1:OVSjKcQEx6JAwGeu8/KQm9Su5qJ72TMEW4xYn5vw3Ac=
 | 
				
			||||||
github.com/VictoriaMetrics/metrics v1.18.0/go.mod h1:ArjwVz7WpgpegX/JpB0zpNF2h2232kErkEnzH1sxMmA=
 | 
					github.com/VictoriaMetrics/metrics v1.40.2/go.mod h1:XE4uudAAIRaJE614Tl5HMrtoEU6+GDZO4QTnNSsZRuA=
 | 
				
			||||||
github.com/ef-ds/deque v1.0.4/go.mod h1:gXDnTC3yqvBcHbq2lcExjtAcVrOnJCbMcZXmuj8Z4tg=
 | 
					github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
 | 
				
			||||||
github.com/golang-jwt/jwt/v4 v4.1.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
 | 
					github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 | 
				
			||||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
 | 
					github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
 | 
				
			||||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
 | 
					github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
 | 
				
			||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 | 
					github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
 | 
				
			||||||
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
 | 
					github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
 | 
				
			||||||
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
 | 
					github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
 | 
				
			||||||
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
 | 
					github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
 | 
				
			||||||
github.com/silas/dag v0.0.0-20210626123444-3804bac2d6d4/go.mod h1:7RTUFBdIRC9nZ7/3RyRNH1bdqIShrDejd1YbLwgPS+I=
 | 
					github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
 | 
				
			||||||
github.com/unistack-org/micro-proto v0.0.9 h1:KrWLS4FUX7UAWNAilQf70uad6ZPf/0EudeddCXllRVc=
 | 
					github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 | 
				
			||||||
github.com/unistack-org/micro-proto v0.0.9/go.mod h1:Cckwmzd89gvS7ThxzZp9kQR/EOdksFQcsTAtDDyKwrg=
 | 
					github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
 | 
				
			||||||
 | 
					github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
 | 
				
			||||||
 | 
					github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
 | 
				
			||||||
 | 
					github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
 | 
				
			||||||
 | 
					github.com/matoous/go-nanoid v1.5.1 h1:aCjdvTyO9LLnTIi0fgdXhOPPvOHjpXN6Ik9DaNjIct4=
 | 
				
			||||||
 | 
					github.com/matoous/go-nanoid v1.5.1/go.mod h1:zyD2a71IubI24efhpvkJz+ZwfwagzgSO6UNiFsZKN7U=
 | 
				
			||||||
 | 
					github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
 | 
				
			||||||
 | 
					github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 | 
				
			||||||
 | 
					github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
 | 
				
			||||||
 | 
					github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
 | 
				
			||||||
 | 
					github.com/spf13/cast v1.8.0 h1:gEN9K4b8Xws4EX0+a0reLmhq8moKn7ntRlQYgjPeCDk=
 | 
				
			||||||
 | 
					github.com/spf13/cast v1.8.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
 | 
				
			||||||
 | 
					github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
 | 
				
			||||||
 | 
					github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
 | 
				
			||||||
github.com/valyala/fastrand v1.1.0 h1:f+5HkLW4rsgzdNoleUOB69hyT9IlD2ZQh9GyDMfb5G8=
 | 
					github.com/valyala/fastrand v1.1.0 h1:f+5HkLW4rsgzdNoleUOB69hyT9IlD2ZQh9GyDMfb5G8=
 | 
				
			||||||
github.com/valyala/fastrand v1.1.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002oeRzjapQ=
 | 
					github.com/valyala/fastrand v1.1.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002oeRzjapQ=
 | 
				
			||||||
github.com/valyala/histogram v1.2.0 h1:wyYGAZZt3CpwUiIb9AU/Zbllg1llXyrtApRS815OLoQ=
 | 
					github.com/valyala/histogram v1.2.0 h1:wyYGAZZt3CpwUiIb9AU/Zbllg1llXyrtApRS815OLoQ=
 | 
				
			||||||
github.com/valyala/histogram v1.2.0/go.mod h1:Hb4kBwb4UxsaNbbbh+RRz8ZR6pdodR57tzWUS3BUzXY=
 | 
					github.com/valyala/histogram v1.2.0/go.mod h1:Hb4kBwb4UxsaNbbbh+RRz8ZR6pdodR57tzWUS3BUzXY=
 | 
				
			||||||
go.unistack.org/micro/v3 v3.8.0 h1:9k6C40xdJf65VW6cVB8sOJVSJhyz1UfFOhX7/II2ivo=
 | 
					go.unistack.org/micro-proto/v4 v4.1.0 h1:qPwL2n/oqh9RE3RTTDgt28XK3QzV597VugQPaw9lKUk=
 | 
				
			||||||
go.unistack.org/micro/v3 v3.8.0/go.mod h1:Tkteri0wiiybbH6aPqay26pZHFIAwL9LXJc2x1Jkakk=
 | 
					go.unistack.org/micro-proto/v4 v4.1.0/go.mod h1:ArmK7o+uFvxSY3dbJhKBBX4Pm1rhWdLEFf3LxBrMtec=
 | 
				
			||||||
golang.org/x/net v0.0.0-20210928044308-7d9f5e0b762b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
 | 
					go.unistack.org/micro/v4 v4.1.22 h1:CBRwTxj53gtFkQKyzUeoIad9LyyJaMCJDcsmzUwXHdI=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					go.unistack.org/micro/v4 v4.1.22/go.mod h1:nlBXTbx0rQrSZX4HPp2m57PHmpuGPWUd0O+jpUIiPto=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
 | 
				
			||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 | 
					golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
 | 
				
			||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 | 
					golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
 | 
				
			||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 | 
					golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
 | 
				
			||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
					golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
 | 
				
			||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
 | 
					golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
 | 
				
			||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
					google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a h1:51aaUVRocpvUOSQKM6Q7VuoaktNIaMCLuhZB6DKksq4=
 | 
				
			||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
 | 
					google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a/go.mod h1:uRxBH1mhmO8PGhU89cMcHaXKZqO+OfakD8QQO0oYwlQ=
 | 
				
			||||||
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
 | 
					google.golang.org/grpc v1.72.0 h1:S7UkcVa60b5AAQTaO6ZKamFp1zMZSU0fGDK2WZLbBnM=
 | 
				
			||||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
 | 
					google.golang.org/grpc v1.72.0/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM=
 | 
				
			||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 | 
					google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
 | 
				
			||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 | 
					google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
 | 
				
			||||||
 | 
					gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
 | 
				
			||||||
 | 
					gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,40 +5,53 @@ import (
 | 
				
			|||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/VictoriaMetrics/metrics"
 | 
						"github.com/VictoriaMetrics/metrics"
 | 
				
			||||||
	"go.unistack.org/micro/v3/meter"
 | 
						"go.unistack.org/micro/v4/meter"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type victoriametricsMeter struct {
 | 
					type victoriametricsMeter struct {
 | 
				
			||||||
	set  *metrics.Set
 | 
						set              *metrics.Set
 | 
				
			||||||
	opts meter.Options
 | 
						opts             meter.Options
 | 
				
			||||||
 | 
						prometheusCompat bool
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func NewMeter(opts ...meter.Option) meter.Meter {
 | 
					func NewMeter(opts ...meter.Option) meter.Meter {
 | 
				
			||||||
	return &victoriametricsMeter{set: metrics.NewSet(), opts: meter.NewOptions(opts...)}
 | 
						m := &victoriametricsMeter{set: metrics.NewSet(), opts: meter.NewOptions(opts...)}
 | 
				
			||||||
 | 
						if v, ok := m.opts.Context.Value(prometheusCompatKey{}).(bool); ok && v {
 | 
				
			||||||
 | 
							m.prometheusCompat = v
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return m
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (r *victoriametricsMeter) Name() string {
 | 
					func (r *victoriametricsMeter) Name() string {
 | 
				
			||||||
	return r.opts.Name
 | 
						return r.opts.Name
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (r *victoriametricsMeter) buildName(name string, labels ...string) string {
 | 
					func (r *victoriametricsMeter) Unregister(name string, labels ...string) bool {
 | 
				
			||||||
	if len(r.opts.MetricPrefix) > 0 {
 | 
						return r.set.UnregisterMetric(r.buildName(name, labels...))
 | 
				
			||||||
		name = r.opts.MetricPrefix + name
 | 
					}
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(labels) == 0 {
 | 
					func (r *victoriametricsMeter) Clone(opts ...meter.Option) meter.Meter {
 | 
				
			||||||
 | 
						options := r.opts
 | 
				
			||||||
 | 
						for _, o := range opts {
 | 
				
			||||||
 | 
							o(&options)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						m := &victoriametricsMeter{set: r.set, opts: options}
 | 
				
			||||||
 | 
						if v, ok := m.opts.Context.Value(prometheusCompatKey{}).(bool); ok && v {
 | 
				
			||||||
 | 
							m.prometheusCompat = v
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return m
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (r *victoriametricsMeter) buildName(name string, labels ...string) string {
 | 
				
			||||||
 | 
						nl := len(r.opts.Labels) + len(labels)
 | 
				
			||||||
 | 
						if nl == 0 {
 | 
				
			||||||
		return name
 | 
							return name
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(r.opts.LabelPrefix) == 0 {
 | 
						nlabels := make([]string, 0, nl)
 | 
				
			||||||
		return meter.BuildName(name, labels...)
 | 
						nlabels = append(nlabels, r.opts.Labels...)
 | 
				
			||||||
	}
 | 
						nlabels = append(nlabels, labels...)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	nlabels := make([]string, len(labels))
 | 
					 | 
				
			||||||
	copy(nlabels, labels)
 | 
					 | 
				
			||||||
	for idx := 0; idx <= len(nlabels)/2; idx += 2 {
 | 
					 | 
				
			||||||
		nlabels[idx] = r.opts.LabelPrefix + nlabels[idx]
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return meter.BuildName(name, nlabels...)
 | 
						return meter.BuildName(name, nlabels...)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -55,6 +68,9 @@ func (r *victoriametricsMeter) Gauge(name string, f func() float64, labels ...st
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (r *victoriametricsMeter) Histogram(name string, labels ...string) meter.Histogram {
 | 
					func (r *victoriametricsMeter) Histogram(name string, labels ...string) meter.Histogram {
 | 
				
			||||||
 | 
						if r.prometheusCompat {
 | 
				
			||||||
 | 
							return r.set.GetOrCreatePrometheusHistogram(r.buildName(name, labels...))
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	return r.set.GetOrCreateHistogram(r.buildName(name, labels...))
 | 
						return r.set.GetOrCreateHistogram(r.buildName(name, labels...))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -67,7 +83,7 @@ func (r *victoriametricsMeter) SummaryExt(name string, window time.Duration, qua
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (r *victoriametricsMeter) Set(opts ...meter.Option) meter.Meter {
 | 
					func (r *victoriametricsMeter) Set(opts ...meter.Option) meter.Meter {
 | 
				
			||||||
	m := &victoriametricsMeter{opts: r.opts}
 | 
						m := &victoriametricsMeter{opts: r.opts, prometheusCompat: r.prometheusCompat}
 | 
				
			||||||
	for _, o := range opts {
 | 
						for _, o := range opts {
 | 
				
			||||||
		o(&m.opts)
 | 
							o(&m.opts)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -79,7 +95,9 @@ func (r *victoriametricsMeter) Init(opts ...meter.Option) error {
 | 
				
			|||||||
	for _, o := range opts {
 | 
						for _, o := range opts {
 | 
				
			||||||
		o(&r.opts)
 | 
							o(&r.opts)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if v, ok := r.opts.Context.Value(prometheusCompatKey{}).(bool); ok && v {
 | 
				
			||||||
 | 
							r.prometheusCompat = v
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -106,3 +124,9 @@ func (r *victoriametricsMeter) Options() meter.Options {
 | 
				
			|||||||
func (r *victoriametricsMeter) String() string {
 | 
					func (r *victoriametricsMeter) String() string {
 | 
				
			||||||
	return "victoriametrics"
 | 
						return "victoriametrics"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type prometheusCompatKey struct{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func PrometheusCompat(b bool) meter.Option {
 | 
				
			||||||
 | 
						return meter.SetOption(prometheusCompatKey{}, b)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,17 +5,29 @@ import (
 | 
				
			|||||||
	"context"
 | 
						"context"
 | 
				
			||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"go.unistack.org/micro/v3/client"
 | 
						"go.unistack.org/micro/v4/client"
 | 
				
			||||||
	"go.unistack.org/micro/v3/codec"
 | 
						"go.unistack.org/micro/v4/codec"
 | 
				
			||||||
	"go.unistack.org/micro/v3/meter"
 | 
						"go.unistack.org/micro/v4/meter"
 | 
				
			||||||
	"go.unistack.org/micro/v3/meter/wrapper"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func BenchmarkBuildName(b *testing.B) {
 | 
				
			||||||
 | 
						m := NewMeter(meter.Labels("pod", "xxx"))
 | 
				
			||||||
 | 
						if err := m.Init(); err != nil {
 | 
				
			||||||
 | 
							b.Fatal(err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						im := m.(*victoriametricsMeter)
 | 
				
			||||||
 | 
						b.ResetTimer()
 | 
				
			||||||
 | 
						for i := 0; i < b.N; i++ {
 | 
				
			||||||
 | 
							name := im.buildName("micro_foo", "bar", "baz", "aaa", "b", "ccc", "d")
 | 
				
			||||||
 | 
							_ = name
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestBuildName(t *testing.T) {
 | 
					func TestBuildName(t *testing.T) {
 | 
				
			||||||
	m := NewMeter()
 | 
						m := NewMeter()
 | 
				
			||||||
	im := m.(*victoriametricsMeter)
 | 
						im := m.(*victoriametricsMeter)
 | 
				
			||||||
	check := `micro_foo{micro_aaa="b",micro_bar="baz"}`
 | 
						check := `micro_foo{bar="baz",aaa="b",ccc="d"}`
 | 
				
			||||||
	name := im.buildName("foo", "bar", "baz", "aaa", "b")
 | 
						name := im.buildName("micro_foo", "bar", "baz", "aaa", "b", "ccc", "d")
 | 
				
			||||||
	if name != check {
 | 
						if name != check {
 | 
				
			||||||
		t.Fatalf("metric name error: %s != %s", name, check)
 | 
							t.Fatalf("metric name error: %s != %s", name, check)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -26,17 +38,12 @@ func TestBuildName(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func TestWrapper(t *testing.T) {
 | 
					func TestWrapper(t *testing.T) {
 | 
				
			||||||
	m := NewMeter()
 | 
						m := NewMeter()
 | 
				
			||||||
 | 
						if err := m.Init(); err != nil {
 | 
				
			||||||
	w := wrapper.NewClientWrapper(
 | 
							t.Fatal(err)
 | 
				
			||||||
		wrapper.ServiceName("svc1"),
 | 
						}
 | 
				
			||||||
		wrapper.ServiceVersion("0.0.1"),
 | 
					 | 
				
			||||||
		wrapper.ServiceID("12345"),
 | 
					 | 
				
			||||||
		wrapper.Meter(m),
 | 
					 | 
				
			||||||
	)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ctx := context.Background()
 | 
						ctx := context.Background()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c := client.NewClient(client.Wrap(w))
 | 
						c := client.NewClient(client.Meter(m))
 | 
				
			||||||
	if err := c.Init(); err != nil {
 | 
						if err := c.Init(); err != nil {
 | 
				
			||||||
		t.Fatal(err)
 | 
							t.Fatal(err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -45,8 +52,8 @@ func TestWrapper(t *testing.T) {
 | 
				
			|||||||
	err := c.Call(ctx, c.NewRequest("svc2", "Service.Method", req), rsp)
 | 
						err := c.Call(ctx, c.NewRequest("svc2", "Service.Method", req), rsp)
 | 
				
			||||||
	_, _ = rsp, err
 | 
						_, _ = rsp, err
 | 
				
			||||||
	buf := bytes.NewBuffer(nil)
 | 
						buf := bytes.NewBuffer(nil)
 | 
				
			||||||
	m.Write(buf, meter.WriteProcessMetrics(false), meter.WriteFDMetrics(false))
 | 
						_ = m.Write(buf, meter.WriteProcessMetrics(false), meter.WriteFDMetrics(false))
 | 
				
			||||||
	if !bytes.Contains(buf.Bytes(), []byte(`micro_client_request_inflight{micro_endpoint="svc2.Service.Method"} 0`)) {
 | 
						if !bytes.Contains(buf.Bytes(), []byte(`micro_client_request_total{endpoint="Service.Method",status="failure",code="500"} 1`)) {
 | 
				
			||||||
		t.Fatalf("invalid metrics output: %s", buf.Bytes())
 | 
							t.Fatalf("invalid metrics output: %s", buf.Bytes())
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user