Skip to content

Commit

Permalink
support http server/client (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktong authored Apr 28, 2024
1 parent 9ef9791 commit 513aa75
Show file tree
Hide file tree
Showing 31 changed files with 1,376 additions and 36 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ updates:
schedule:
interval: weekly

- package-ecosystem: gomod
directory: /http
labels:
- Skip-Changelog
schedule:
interval: weekly

- package-ecosystem: github-actions
directory: /
labels:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
if: ${{ github.actor != 'dependabot[bot]' }}
strategy:
matrix:
module: [ '', 'gcp', 'grpc' ]
module: [ '', 'gcp', 'grpc', 'http' ]
name: Coverage
runs-on: ubuntu-latest
steps:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ jobs:
lint:
strategy:
matrix:
module: [ '', 'gcp', 'grpc', 'examples/grpc' ]
module: [
'', 'gcp',
'grpc', 'examples/grpc',
'http', 'examples/http'
]
name: Lint
runs-on: ubuntu-latest
steps:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ jobs:
script: |
const modules = [
'gcp',
'grpc'
'grpc',
'http'
]
for (const module of modules) {
github.rest.git.createRef({
Expand Down
28 changes: 26 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ jobs:
test:
strategy:
matrix:
module: [ '', 'gcp', 'grpc', 'examples/grpc' ]
module: [
'', 'gcp',
'grpc', 'examples/grpc'
]
go-version: [ 'stable', 'oldstable' ]
name: Test
runs-on: ubuntu-latest
Expand All @@ -27,11 +30,32 @@ jobs:
- name: Test
run: go test -shuffle=on -v ./...
working-directory: ${{ matrix.module }}
test-http:
strategy:
matrix:
module: [
'http', 'examples/http'
]
go-version: [ 'stable' ]
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache-dependency-path: "**/go.sum"
- name: Race Test
run: go test -v -shuffle=on -count=10 -race ./...
working-directory: ${{ matrix.module }}
- name: Test
run: go test -shuffle=on -v ./...
working-directory: ${{ matrix.module }}
all:
if: ${{ always() }}
runs-on: ubuntu-latest
name: All Tests
needs: test
needs: [test, test-http]
steps:
- name: Check test matrix status
if: ${{ needs.test.result != 'success' }}
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- Support gRPC server (#15).
- Add nilgo.Run (#22).
- Support GCP Cloud Run (#24).
- Support HTTP server (#26).
2 changes: 1 addition & 1 deletion examples/grpc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21

require (
cloud.google.com/go/compute/metadata v0.3.0
github.com/nil-go/nilgo v0.0.0-20240415132939-a595e188f79c
github.com/nil-go/nilgo v0.0.0
github.com/nil-go/nilgo/gcp v0.0.0
github.com/nil-go/nilgo/grpc v0.0.0
)
Expand Down
6 changes: 2 additions & 4 deletions examples/grpc/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,8 @@ go.opentelemetry.io/otel v1.26.0 h1:LQwgL5s/1W7YiiRwxf03QGnWLb2HW4pLiAhaA5cZXBs=
go.opentelemetry.io/otel v1.26.0/go.mod h1:UmLkJHUAidDval2EICqBMbnAd0/m2vmpf/dAM+fvFs4=
go.opentelemetry.io/otel/metric v1.26.0 h1:7S39CLuY5Jgg9CrnA9HHiEjGMF/X2VHvoXGgSllRz30=
go.opentelemetry.io/otel/metric v1.26.0/go.mod h1:SY+rHOI4cEawI9a7N1A4nIg/nTQXe1ccCNWYOJUrpX4=
go.opentelemetry.io/otel/sdk v1.26.0 h1:Y7bumHf5tAiDlRYFmGqetNcLaVUZmh4iYfmGxtmz7F8=
go.opentelemetry.io/otel/sdk v1.26.0/go.mod h1:0p8MXpqLeJ0pzcszQQN4F0S5FVjBLgypeGSngLsmirs=
go.opentelemetry.io/otel/sdk/metric v1.26.0 h1:cWSks5tfriHPdWFnl+qpX3P681aAYqlZHcAyHw5aU9Y=
go.opentelemetry.io/otel/sdk/metric v1.26.0/go.mod h1:ClMFFknnThJCksebJwz7KIyEDHO+nTB6gK8obLy8RyE=
go.opentelemetry.io/otel/sdk v1.22.0 h1:6coWHw9xw7EfClIC/+O31R8IY3/+EiRFHevmHafB2Gw=
go.opentelemetry.io/otel/sdk v1.22.0/go.mod h1:iu7luyVGYovrRpe2fmj3CVKouQNdTOkxtLzPvPz1DOc=
go.opentelemetry.io/otel/trace v1.26.0 h1:1ieeAUb4y0TE26jUFrCIXKpTuVK7uJGN9/Z/2LP5sQA=
go.opentelemetry.io/otel/trace v1.26.0/go.mod h1:4iDxvGDQuUkHve82hJJ8UqrwswHYsZuWCBllGV2U2y0=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down
Empty file.
Empty file.
Empty file.
35 changes: 35 additions & 0 deletions examples/http/cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) 2024 The nilgo authors
// Use of this source code is governed by a MIT license found in the LICENSE file.

package main

import (
"embed"
"net/http"
"time"

"cloud.google.com/go/compute/metadata"

"github.com/nil-go/nilgo"
"github.com/nil-go/nilgo/config"
"github.com/nil-go/nilgo/gcp"
nhttp "github.com/nil-go/nilgo/http"
)

//go:embed config
var configFS embed.FS

func main() {
var opts []any
if metadata.OnGCE() {
opts = gcp.Options()
}
opts = append(opts,
config.WithFS(configFS),
nhttp.Run(&http.Server{ReadTimeout: time.Second}),
)

if err := nilgo.Run(opts...); err != nil {
panic(err)
}
}
58 changes: 58 additions & 0 deletions examples/http/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
module github.com/nil-go/nilgo/examples/http

go 1.22

toolchain go1.22.2

require (
cloud.google.com/go/compute/metadata v0.3.0
github.com/nil-go/nilgo v0.0.0
github.com/nil-go/nilgo/gcp v0.0.0
github.com/nil-go/nilgo/http v0.0.0
)

replace (
github.com/nil-go/nilgo => ./../..
github.com/nil-go/nilgo/gcp => ./../../gcp
github.com/nil-go/nilgo/http => ./../../http
)

require (
cloud.google.com/go v0.112.2 // indirect
cloud.google.com/go/auth v0.3.0 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
cloud.google.com/go/profiler v0.4.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.3 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/nil-go/konf v1.1.0 // indirect
github.com/nil-go/sloth v0.3.0 // indirect
github.com/nil-go/sloth/otel v0.3.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0 // indirect
go.opentelemetry.io/otel v1.26.0 // indirect
go.opentelemetry.io/otel/metric v1.26.0 // indirect
go.opentelemetry.io/otel/trace v1.26.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.19.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.176.1 // indirect
google.golang.org/genproto v0.0.0-20240415180920-8c6c420018be // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 513aa75

Please sign in to comment.