Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sql): Provided module #217

Merged
merged 17 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
- "httpserver"
- "log"
- "orm"
- "sql"
- "trace"
- "worker"
- "fxcore"
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/sql-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "sql-ci"

on:
push:
branches:
- "feat**"
- "fix**"
- "hotfix**"
- "chore**"
paths:
- "sql/**.go"
- "sql/go.mod"
- "sql/go.sum"
pull_request:
types:
- opened
- synchronize
- reopened
branches:
- main
paths:
- "sql/**.go"
- "sql/go.mod"
- "sql/go.sum"

jobs:
ci:
uses: ./.github/workflows/common-ci.yml
secrets: inherit
with:
module: "sql"
5 changes: 5 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
"component": "orm",
"tag-separator": "/"
},
"sql": {
"release-type": "go",
"component": "sql",
"tag-separator": "/"
},
"trace": {
"release-type": "go",
"component": "trace",
Expand Down
65 changes: 65 additions & 0 deletions sql/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
run:
timeout: 5m
concurrency: 8

linters:
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- cyclop
- decorder
- dogsled
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- exhaustive
- forbidigo
- forcetypeassert
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- godox
- gofmt
- goheader
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- grouper
- importas
- ineffassign
- interfacebloat
- logrlint
- maintidx
- makezero
- misspell
- nestif
- nilerr
- nilnil
- nlreturn
- nolintlint
- nosprintfhostport
- prealloc
- predeclared
- promlinter
- reassign
- staticcheck
- tenv
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- whitespace
25 changes: 25 additions & 0 deletions sql/configuration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package sql

// Configuration is the SQL components (driver, connector, connection, etc) configuration.
type Configuration struct {
system System
hooks []Hook
}

// NewConfiguration returns a new Configuration.
func NewConfiguration(system System, hooks ...Hook) *Configuration {
return &Configuration{
system: system,
hooks: hooks,
}
}

// System returns the Configuration System.
func (c *Configuration) System() System {
return c.system
}

// Hooks returns the Configuration list of Hook.
func (c *Configuration) Hooks() []Hook {
return c.hooks
}
24 changes: 24 additions & 0 deletions sql/configuration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package sql_test

import (
"testing"

"github.com/ankorstore/yokai/sql"
"github.com/ankorstore/yokai/sql/hook/log"
"github.com/ankorstore/yokai/sql/hook/trace"
"github.com/stretchr/testify/assert"
)

func TestNewConfiguration(t *testing.T) {
t.Parallel()

hooks := []sql.Hook{
trace.NewTraceHook(),
log.NewLogHook(),
}

config := sql.NewConfiguration(sql.SqliteSystem, hooks...)

assert.Equal(t, sql.SqliteSystem, config.System())
assert.Equal(t, hooks, config.Hooks())
}
Loading
Loading