-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c17a2b0
Showing
3,524 changed files
with
1,195,470 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
version: 2 | ||
|
||
updates: | ||
- package-ecosystem: gomod | ||
directory: / | ||
labels: | ||
- dependencies | ||
schedule: | ||
interval: daily | ||
|
||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
labels: | ||
- dependencies | ||
schedule: | ||
interval: "daily" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Build and Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
version: ["stable"] | ||
services: | ||
# Label used to access the service container | ||
redis: | ||
# Docker Hub image | ||
image: redis | ||
# Set health checks to wait until redis has started | ||
options: >- | ||
--health-cmd "redis-cli ping" | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
# Maps port 6379 on service container to the host | ||
- 6379:6379 | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ matrix.version }} | ||
cache: true | ||
|
||
- name: Install Task | ||
uses: arduino/setup-task@v1 | ||
with: | ||
version: 3.x | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: generate and test | ||
run: | | ||
task github-action | ||
- uses: codecov/codecov-action@v3 | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
with: | ||
files: ./coverage.out # optional | ||
flags: unittests # optional | ||
name: codecov-umbrella # optional | ||
fail_ci_if_error: true # optional (default = false) | ||
verbose: true # optional (default = false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig | ||
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,linux,go | ||
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,linux,go | ||
|
||
### Go ### | ||
# If you prefer the allow list template instead of the deny list, see community template: | ||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore | ||
# | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
# Go workspace file | ||
go.work | ||
go.work.sum | ||
|
||
### Linux ### | ||
*~ | ||
|
||
# temporary files which can be created if a process still has a handle open of a deleted file | ||
.fuse_hidden* | ||
|
||
# KDE directory preferences | ||
.directory | ||
|
||
# Linux trash folder which might appear on any partition or disk | ||
.Trash-* | ||
|
||
# .nfs files are created when an open file is removed but is still being accessed | ||
.nfs* | ||
|
||
### VisualStudioCode ### | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
!.vscode/*.code-snippets | ||
|
||
# Local History for Visual Studio Code | ||
.history/ | ||
|
||
# Built Visual Studio Code Extensions | ||
*.vsix | ||
|
||
### VisualStudioCode Patch ### | ||
# Ignore all local history of files | ||
.history | ||
.ionide | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,linux,go | ||
|
||
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Kod Ext | ||
=== | ||
|
||
[![Build and Test](https://github.com/go-kod/kod-ext/actions/workflows/go.yml/badge.svg)](https://github.com/go-kod/kod-ext/actions/workflows/go.yml) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
version: '3' | ||
|
||
tasks: | ||
default: | ||
cmds: | ||
- task: generate | ||
- task: mod | ||
- task: lint:golangci-lint | ||
|
||
github-action: | ||
cmds: | ||
# - task: generate | ||
- task: lint:golangci-lint | ||
- task: lint:files-changed | ||
- task: test | ||
|
||
generate:struct2interface: | ||
cmds: | ||
- go run github.com/go-kod/kod/cmd/kod struct2interface . | ||
deps: | ||
- install:mockgen | ||
|
||
generate: | ||
cmds: | ||
- go run github.com/go-kod/kod/cmd/kod generate ./... | ||
deps: | ||
- generate:struct2interface | ||
|
||
lint:golangci-lint: | ||
cmd: | | ||
golangci-lint run ./... | ||
deps: | ||
- install:golangci-lint | ||
|
||
lint:files-changed: | ||
cmd: | | ||
git diff --exit-code | ||
test: | ||
cmd: | | ||
go test -race -cover -coverprofile=coverage.out -covermode=atomic ./... -coverpkg ./... | ||
sources: | ||
- "**/**.go" | ||
generates: | ||
- coverage.out | ||
|
||
test:coverage: | ||
cmd: | | ||
go tool cover -func=coverage.out | ||
deps: | ||
- test | ||
|
||
install:mockgen: | ||
vars: | ||
VERSION: v0.3.0 | ||
status: | ||
- go version -m $GOPATH/bin/mockgen | grep go.uber.org/mock | grep {{.VERSION}} | ||
cmd: | | ||
go install go.uber.org/mock/mockgen@{{.VERSION}} | ||
install:golangci-lint: | ||
vars: | ||
VERSION: v1.54.2 | ||
status: | ||
- go version -m $GOPATH/bin/golangci-lint | grep github.com/golangci/golangci-lint | grep {{.VERSION}} | ||
cmd: | | ||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@{{.VERSION}} | ||
install:kod: | ||
vars: | ||
VERSION: devel | ||
status: | ||
- go version -m $GOPATH/bin/kod | grep github.com/go-kod/kod | grep {{.VERSION}} | ||
cmd: | | ||
go install github.com/go-kod/kod/cmd/kod@{{.VERSION}} | ||
mod: | ||
cmds: | ||
- go mod tidy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package ketcdv3 | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"time" | ||
|
||
"dario.cat/mergo" | ||
clientv3 "go.etcd.io/etcd/client/v3" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
type Config struct { | ||
Endpoints []string | ||
Timeout time.Duration | ||
} | ||
|
||
func (r Config) Build(ctx context.Context) (*clientv3.Client, error) { | ||
|
||
err := mergo.Merge(&r, Config{ | ||
Endpoints: []string{"localhost:2379"}, | ||
Timeout: 3 * time.Second, | ||
}) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to merge config: %w", err) | ||
} | ||
|
||
etcd, err := clientv3.New(clientv3.Config{ | ||
Endpoints: r.Endpoints, | ||
DialTimeout: r.Timeout, | ||
DialOptions: []grpc.DialOption{grpc.WithBlock()}, | ||
}) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to create etcd client: %w", err) | ||
} | ||
|
||
return etcd, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package kgorm | ||
|
||
import ( | ||
"gorm.io/driver/mysql" | ||
"gorm.io/gorm" | ||
"gorm.io/plugin/opentelemetry/tracing" | ||
) | ||
|
||
type Config struct { | ||
Dsn string | ||
} | ||
|
||
func (c Config) Build() *DB { | ||
db, err := gorm.Open(mysql.Open(c.Dsn), &gorm.Config{}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
if err := db.Use(tracing.NewPlugin()); err != nil { | ||
panic(err) | ||
} | ||
|
||
return db | ||
} | ||
|
||
type ( | ||
// DB is an alias for gorm.DB. | ||
DB = gorm.DB | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package kgrpc | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"dario.cat/mergo" | ||
"github.com/go-kod/kod-ext/registry" | ||
"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/retry" | ||
"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/timeout" | ||
"github.com/samber/lo" | ||
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc" | ||
"google.golang.org/grpc" | ||
"google.golang.org/grpc/credentials/insecure" | ||
) | ||
|
||
type ClientConn = grpc.ClientConn | ||
|
||
type Config struct { | ||
Target string | ||
Timeout time.Duration | ||
|
||
registry registry.Registry | ||
} | ||
|
||
func (c Config) WithRegistry(r registry.Registry) Config { | ||
c.registry = r | ||
return c | ||
} | ||
|
||
func (c Config) Build(opts ...grpc.DialOption) *ClientConn { | ||
lo.Must0(mergo.Merge(&c, Config{ | ||
Timeout: 3 * time.Second, | ||
})) | ||
|
||
ctx := context.Background() | ||
|
||
defaultOpts := []grpc.DialOption{ | ||
grpc.WithNoProxy(), | ||
grpc.WithStatsHandler(otelgrpc.NewClientHandler()), | ||
grpc.WithTransportCredentials(insecure.NewCredentials()), | ||
grpc.WithChainUnaryInterceptor( | ||
retry.UnaryClientInterceptor(), | ||
timeout.UnaryClientInterceptor(c.Timeout), | ||
), | ||
grpc.WithChainStreamInterceptor( | ||
retry.StreamClientInterceptor(), | ||
), | ||
} | ||
|
||
if c.registry != nil { | ||
builder, err := c.registry.ResolveBuilder(ctx) | ||
if err != nil { | ||
panic(err) | ||
} | ||
defaultOpts = append(defaultOpts, grpc.WithResolvers(builder)) | ||
} | ||
|
||
defaultOpts = append(defaultOpts, opts...) | ||
|
||
cc, err := grpc.DialContext(ctx, c.Target, defaultOpts...) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
return cc | ||
} |
Oops, something went wrong.