Skip to content

Commit 7527bf8

Browse files
committed
feat: first version
0 parents  commit 7527bf8

14 files changed

Lines changed: 557 additions & 0 deletions

.editorconfig

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = LF
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
indent_style = space
9+
indent_size = 4
10+
11+
[Makefile]
12+
indent_style = tab
13+
14+
[*.md]
15+
trim_trailing_whitespace = false
16+
17+
[*.go]
18+
indent_style = tab
19+
20+
[*.yml]
21+
indent_size = 2
22+
23+
[*.yaml]
24+
indent_size = 2
25+
26+
[*.yml.dist]
27+
indent_size = 2

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: gomod
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
time: "04:00"
8+
open-pull-requests-limit: 10
9+
assignees:
10+
- euskadi31

.github/workflows/go.yml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
name: Go
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
11+
build:
12+
name: Build
13+
runs-on: ubuntu-latest
14+
steps:
15+
16+
- name: Set up Go 1.x
17+
uses: actions/setup-go@v2
18+
with:
19+
go-version: ^1.17
20+
id: go
21+
22+
- name: Check out code into the Go module directory
23+
uses: actions/checkout@v2
24+
25+
- name: Build
26+
run: go build -race -v ./...
27+
28+
- name: Test
29+
run: go test -race -cover -coverprofile ./coverage.out ./...
30+
31+
- name: Coverage
32+
id: coverage
33+
run: |
34+
go tool cover -func ./coverage.out | tee -a coverage.txt
35+
echo "COVERAGE_CONTENT<<EOF" >> $GITHUB_ENV
36+
cat coverage.txt >> $GITHUB_ENV
37+
echo "EOF" >> $GITHUB_ENV
38+
39+
- uses: actions/github-script@v4
40+
if: github.event_name == 'pull_request'
41+
continue-on-error: true
42+
env:
43+
COVERAGE_CONTENT: "${{ env.COVERAGE_CONTENT }}"
44+
with:
45+
github-token: ${{ secrets.GITHUB_TOKEN }}
46+
script: |
47+
const output = `Code Coverage\n
48+
\`\`\`\n
49+
${process.env.COVERAGE_CONTENT}
50+
\`\`\`
51+
52+
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Workflow: \`${{ github.workflow }}\`*`;
53+
54+
const response = await github.issues.listComments({
55+
owner: context.repo.owner,
56+
repo: context.repo.repo,
57+
issue_number: context.issue.number,
58+
});
59+
60+
var comments = response.data;
61+
62+
console.log(comments);
63+
64+
if (comments.length > 0) {
65+
comments = comments.filter(comment => comment.body.includes('Code Coverage') && comment.user.type === 'Bot');
66+
}
67+
68+
if (comments.length > 0) {
69+
const comment = comments.shift();
70+
71+
github.issues.updateComment({
72+
issue_number: context.issue.number,
73+
owner: context.repo.owner,
74+
repo: context.repo.repo,
75+
comment_id: comment.id,
76+
body: output
77+
})
78+
} else {
79+
github.issues.createComment({
80+
issue_number: context.issue.number,
81+
owner: context.repo.owner,
82+
repo: context.repo.repo,
83+
body: output
84+
})
85+
}
86+
87+
88+
- name: Benchmark
89+
id: benchmark
90+
run: |
91+
go test -benchmem -bench . | tee -a benchmark.txt
92+
echo "BENCHMARK_CONTENT<<EOF" >> $GITHUB_ENV
93+
cat benchmark.txt >> $GITHUB_ENV
94+
echo "EOF" >> $GITHUB_ENV
95+
96+
- uses: actions/github-script@v4
97+
if: github.event_name == 'pull_request'
98+
continue-on-error: true
99+
env:
100+
BENCHMARK_CONTENT: "${{ env.BENCHMARK_CONTENT }}"
101+
with:
102+
github-token: ${{ secrets.GITHUB_TOKEN }}
103+
script: |
104+
const output = `Benchmark\n
105+
\`\`\`\n
106+
${process.env.BENCHMARK_CONTENT}
107+
\`\`\`
108+
109+
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Workflow: \`${{ github.workflow }}\`*`;
110+
111+
const response = await github.issues.listComments({
112+
owner: context.repo.owner,
113+
repo: context.repo.repo,
114+
issue_number: context.issue.number,
115+
});
116+
117+
var comments = response.data;
118+
119+
console.log(comments);
120+
121+
if (comments.length > 0) {
122+
comments = comments.filter(comment => comment.body.includes('Benchmark') && comment.user.type === 'Bot');
123+
}
124+
125+
if (comments.length > 0) {
126+
const comment = comments.shift();
127+
128+
github.issues.updateComment({
129+
issue_number: context.issue.number,
130+
owner: context.repo.owner,
131+
repo: context.repo.repo,
132+
comment_id: comment.id,
133+
body: output
134+
})
135+
} else {
136+
github.issues.createComment({
137+
issue_number: context.issue.number,
138+
owner: context.repo.owner,
139+
repo: context.repo.repo,
140+
body: output
141+
})
142+
}
143+
144+
- name: Run golangci-lint
145+
uses: golangci/golangci-lint-action@v3.2.0
146+
with:
147+
version: v1.46.2
148+
skip-pkg-cache: true
149+
150+
- name: Coveralls
151+
uses: shogo82148/actions-goveralls@v1
152+
with:
153+
path-to-profile: coverage.out

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
*.out
3+
4+
.vscode/
5+
vendor/
6+
7+
*.swp

.golangci.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
run:
2+
concurrency: 4
3+
deadline: 1m
4+
issues-exit-code: 1
5+
tests: false
6+
skip-files:
7+
- ".*_mock\\.go"
8+
- "mock_.*\\.go"
9+
- ".*/pkg/mod/.*$"
10+
11+
output:
12+
format: colored-line-number
13+
print-issued-lines: true
14+
print-linter-name: true
15+
16+
linters-settings:
17+
errcheck:
18+
check-type-assertions: false
19+
check-blank: false
20+
govet:
21+
check-shadowing: false
22+
revive:
23+
ignore-generated-header: true
24+
severity: warning
25+
gofmt:
26+
simplify: true
27+
gocyclo:
28+
min-complexity: 18
29+
maligned:
30+
suggest-new: true
31+
dupl:
32+
threshold: 80
33+
goconst:
34+
min-len: 4
35+
min-occurrences: 3
36+
depguard:
37+
list-type: blacklist
38+
include-go-root: false
39+
packages:
40+
- github.com/davecgh/go-spew/spew
41+
misspell:
42+
locale: US
43+
ignore-words:
44+
- cancelled
45+
goimports:
46+
local-prefixes: go.opentelemetry.io
47+
48+
49+
linters:
50+
disable-all: true
51+
enable:
52+
- deadcode
53+
- depguard
54+
- errcheck
55+
- gas
56+
- goconst
57+
- gocyclo
58+
- gofmt
59+
- revive
60+
- govet
61+
- ineffassign
62+
- megacheck
63+
- misspell
64+
- structcheck
65+
- typecheck
66+
- unconvert
67+
- varcheck
68+
- gosimple
69+
- staticcheck
70+
- unused
71+
- asciicheck
72+
- bodyclose
73+
- dogsled
74+
- dupl
75+
- durationcheck
76+
- errorlint
77+
- exhaustive
78+
- exportloopref
79+
- forbidigo
80+
- forcetypeassert
81+
- gocritic
82+
- godot
83+
- gosec
84+
- ifshort
85+
- nestif
86+
- nilerr
87+
- nlreturn
88+
- noctx
89+
- prealloc
90+
- predeclared
91+
- sqlclosecheck
92+
- tagliatelle
93+
- whitespace
94+
- wsl
95+
fast: false

LICENSE.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2022 Axel Etcheverry
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is furnished
8+
to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.PHONY: all clean test cover travis lint
2+
3+
release:
4+
@echo "Release v$(version)"
5+
@git pull
6+
@git checkout master
7+
@git pull
8+
@git checkout develop
9+
@git flow release start $(version)
10+
@git flow release finish $(version) -p -m "Release v$(version)"
11+
@git checkout develop
12+
@echo "Release v$(version) finished."
13+
14+
all: test
15+
16+
clean:
17+
@go clean -i ./...
18+
19+
coverage.out: $(shell find . -type f -print | grep -v vendor | grep "\.go")
20+
@go test -race -cover -coverprofile ./coverage.out.tmp ./...
21+
@cat ./coverage.out.tmp | grep -v '.pb.go' | grep -v 'mock_' > ./coverage.out
22+
@rm ./coverage.out.tmp
23+
24+
test: coverage.out
25+
26+
lint:
27+
@golangci-lint run
28+
29+
cover: coverage.out
30+
@echo ""
31+
@go tool cover -func ./coverage.out
32+

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Hyperscale Server [![Last release](https://img.shields.io/github/release/hyperscale-stack/server.svg)](https://github.com/hyperscale-stack/server/releases/latest) [![Documentation](https://godoc.org/github.com/hyperscale-stack/server?status.svg)](https://godoc.org/github.com/hyperscale-stack/server)
2+
3+
[![Go Report Card](https://goreportcard.com/badge/github.com/hyperscale-stack/server)](https://goreportcard.com/report/github.com/hyperscale-stack/server)
4+
5+
| Branch | Status | Coverage |
6+
| ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
7+
| master | [![Build Status](https://github.com/hyperscale-stack/server/workflows/Go/badge.svg?branch=master)](https://github.com/hyperscale-stack/server/actions?query=workflow%3AGo) | [![Coveralls](https://img.shields.io/coveralls/hyperscale-stack/server/master.svg)](https://coveralls.io/github/hyperscale-stack/server?branch=master) |
8+
9+
The Hyperscale server library provides a simple server over Fiber.
10+
11+
## Example
12+
13+
```go
14+
package main
15+
16+
import (
17+
"github.com/hyperscale-stack/server"
18+
)
19+
20+
func main() {
21+
app := server.New()
22+
23+
app.AddController(&myController{})
24+
25+
app.Listen(":3000")
26+
}
27+
28+
```
29+
30+
## License
31+
32+
Hyperscale Server is licensed under [the MIT license](LICENSE.md).

controller.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2022 Axel Etcheverry. All rights reserved.
2+
// Use of this source code is governed by a MIT
3+
// license that can be found in the LICENSE file.
4+
5+
package server
6+
7+
// Controller interface
8+
//
9+
//go:generate go run -mod=mod github.com/vektra/mockery/v2 --inpackage --case underscore --name=Controller
10+
type Controller interface {
11+
Mount(r *Router)
12+
}

0 commit comments

Comments
 (0)