Skip to content

Commit

Permalink
Merge pull request #1 from sinhashubham95/compat
Browse files Browse the repository at this point in the history
Compatibility Fixes and Template Additions
  • Loading branch information
sinhashubham95 authored Jul 26, 2021
2 parents c592751 + 24a2f43 commit ad1b1e7
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 27 deletions.
53 changes: 53 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
- With issues:

- Use the search tool before opening a new issue.

- Please provide source code and commit sha if you found a bug.

- Review existing issues and provide feedback or react to them.

## Description

<!-- Description of a problem -->

## How to reproduce

<!-- The smallest possible code example to show the problem that can be compiled, like -->

```
package main
import (
"github.com/sinhashubham95/go-actuator"
)
func main() {
// actuator configuration
}
```

## Expectations

<!-- Your expectation result of 'curl' command, like -->

```
$ curl http://localhost:8201/actuator/[endpoint]
Hello world
```

## Actual result

<!-- Actual result showing the problem -->

```
$ curl -i http://localhost:8201/actuator/[endpoint]
<YOUR RESULT>
```

## Environment

- go version:

- go-actuator version (or commit ref):

- operating system:
11 changes: 11 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- With pull requests:

- Open your pull request against `master`

- Your pull request should have no more than two commits, if not you should squash them.

- It should pass all tests in the available continuous integration GitHub Actions.

- You should add/modify tests to cover your proposed code changes.

- If your pull request contains a new feature, please document it on the [README](../README.md).
16 changes: 3 additions & 13 deletions .github/workflows/go.yml → .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
name: Go
name: Release

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
test:
name: Test
strategy:
matrix:
go-version: [1.13.x, 1.14.x, 1.15.x, 1.16.x]
platform: [ubuntu-latest, macos-latest, windows-latest]
platform: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
Expand All @@ -25,12 +23,8 @@ jobs:
- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Run tests
run: go test -v -coverprofile=profile.cov ./...
run: go test ./... -coverprofile profile.cov
- name: Send coverage
uses: shogo82148/actions-goveralls@v1
with:
Expand Down Expand Up @@ -63,9 +57,5 @@ jobs:
- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Build
run: go build -v
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Test

on:
pull_request:
branches: [master]

jobs:
test:
name: Test
strategy:
matrix:
go-version: [1.13.x, 1.14.x, 1.15.x, 1.16.x]
platform: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Run tests
run: go test ./... -coverprofile profile.cov
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ coverage.out

__debug_bin

profile.cov
profile.cov
profile.out
21 changes: 21 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Contributing

- With issues:

- Use the search tool before opening a new issue.

- Please provide source code and commit sha if you found a bug.

- Review existing issues and provide feedback or react to them.

- With pull requests:

- Open your pull request against `master`

- Your pull request should have no more than two commits, if not you should squash them.

- It should pass all tests in the available continuous integration systems such as GitHub Actions.

- You should add/modify tests to cover your proposed code changes.

- If your pull request contains a new feature, please document it on the README.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,20 @@ Go actuator uses [semantic versioning](http://semver.org/). API should not chang

## Installation

To install Gin package, you need to install Go and set your Go workspace first.

1. The first need Go installed (version 1.13+ is required), then you can use the below Go command to install Go Actuator.

```shell
go get github.com/sinhashubham95/go-actuator
```

2. Import it in your code:

```go
import "github.com/sinhashubham95/go-actuator"
```

## How to Use

The actuator library is compatible with the most famous web frameworks. This is highly configurable and each endpoint can be enabled or disabled during initialization. You can also specify a prefix path for each of these configured endpoints(with default value `/actuator`).
Expand Down
2 changes: 1 addition & 1 deletion controllers/fasthttp/commons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var encodeJSON = commons.EncodeJSON
var getThreadDump = core.GetThreadDump

var portMu sync.Mutex
var port = 1001
var port = 1201

func getRandomPortNumber() int {
portMu.Lock()
Expand Down
13 changes: 1 addition & 12 deletions core/httptrace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,17 @@ import (
"github.com/valyala/fasthttp"
"net/http"
"net/http/httptest"
"sync"
"testing"

"github.com/sinhashubham95/go-actuator/core"
)

var portMu sync.Mutex
var port = 2001

func TestGetHTTPTrace(t *testing.T) {
assert.Empty(t, core.GetHTTPTrace())
}

func TestWithFastHTTP(t *testing.T) {
port := getRandomPortNumber()
port := 2001

go func(endpoint int) {
assert.NoError(t, fasthttp.ListenAndServe(fmt.Sprintf(":%d", port),
Expand Down Expand Up @@ -106,13 +102,6 @@ func TestForMoreThanThresholdRequests(t *testing.T) {
assert.Empty(t, trace.Response.Headers)
}

func getRandomPortNumber() int {
portMu.Lock()
defer portMu.Unlock()
port += 10
return port
}

func setupGINRouter() *gin.Engine {
router := gin.Default()
router.Use(core.GINTracer())
Expand Down

0 comments on commit ad1b1e7

Please sign in to comment.