Skip to content

Commit

Permalink
Merge pull request #88 from osspkg/fix-naming
Browse files Browse the repository at this point in the history
Fix naming
  • Loading branch information
markus621 committed Mar 10, 2024
2 parents b9e26d4 + dc6fb5c commit b02d8f4
Show file tree
Hide file tree
Showing 145 changed files with 769 additions and 937 deletions.
1 change: 0 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

version: 2
updates:
- package-ecosystem: "gomod" # See documentation for possible values
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: CI

on:
Expand Down
21 changes: 10 additions & 11 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: "CodeQL"

on:
Expand All @@ -24,15 +23,15 @@ jobs:
language: [ 'go' ]

steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
9 changes: 4 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# options for analysis running
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
Expand Down Expand Up @@ -160,10 +159,10 @@ linters-settings:
# If 'custom-order' is 'true', it follows the order of 'sections' option.
# Default: ["standard", "default"]
#sections:
#- standard # Standard section: captures all standard packages.
#- default # Default section: contains all imports that could not be matched to another section type.
#- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
#- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
#- standard # Standard section: captures all standard packages.
#- default # Default section: contains all imports that could not be matched to another section type.
#- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
#- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
# Skip generated files.
# Default: true
skip-generated: true
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Goppy Microservice Toolkit
# Goppy Microservice Toolkit

[![Release](https://img.shields.io/github/release/osspkg/goppy.svg?style=flat-square)](https://github.com/osspkg/goppy/releases/latest)
[![Go Report Card](https://goreportcard.com/badge/github.com/osspkg/goppy)](https://goreportcard.com/report/github.com/osspkg/goppy)
[![Release](https://img.shields.io/github/release/osspkg/goppy.svg?style=flat-square)](https://github.com/osspkg/goppy/releases/latest)
[![Go Report Card](https://goreportcard.com/badge/github.com/osspkg/goppy)](https://goreportcard.com/report/github.com/osspkg/goppy)
[![CI](https://github.com/osspkg/goppy/actions/workflows/ci.yml/badge.svg)](https://github.com/osspkg/goppy/actions/workflows/ci.yml)
[![Codeql](https://github.com/osspkg/goppy/actions/workflows/codeql.yml/badge.svg)](https://github.com/osspkg/goppy/actions/workflows/codeql.yml)
![GitHub](https://img.shields.io/github/license/osspkg/goppy)
Expand All @@ -16,12 +16,11 @@
- Built-in dependency container
- Data binding for JSON

## Guide
## Guide

[![guide](https://img.shields.io/badge/giude-goppy.ru-green)](https://goppy.ru)
[![wiki](https://img.shields.io/badge/wiki-github-red)](https://github.com/osspkg/goppy/wiki)


## Contribute

**Use issues for everything**
Expand Down
20 changes: 10 additions & 10 deletions acl/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ type (
}
)

type _acl struct {
type object struct {
cache *cache
store Storage
}

func NewACL(store Storage, size uint) ACL {
return &_acl{
func New(store Storage, size uint) ACL {
return &object{
store: store,
cache: newCache(size),
}
}

func (v *_acl) AutoFlush(ctx context.Context, interval time.Duration) {
func (v *object) AutoFlush(ctx context.Context, interval time.Duration) {
tick := time.NewTicker(interval)
defer tick.Stop()

Expand All @@ -59,7 +59,7 @@ func (v *_acl) AutoFlush(ctx context.Context, interval time.Duration) {
}
}

func (v *_acl) GetAll(email string) ([]uint8, error) {
func (v *object) GetAll(email string) ([]uint8, error) {
if !v.cache.Has(email) {
if err := v.loadFromStore(email); err != nil {
return nil, err
Expand All @@ -69,7 +69,7 @@ func (v *_acl) GetAll(email string) ([]uint8, error) {
return v.cache.GetAll(email)
}

func (v *_acl) Get(email string, feature uint16) (uint8, error) {
func (v *object) Get(email string, feature uint16) (uint8, error) {
if !v.cache.Has(email) {
if err := v.loadFromStore(email); err != nil {
return 0, err
Expand All @@ -79,7 +79,7 @@ func (v *_acl) Get(email string, feature uint16) (uint8, error) {
return v.cache.Get(email, feature)
}

func (v *_acl) Set(email string, feature uint16, level uint8) error {
func (v *object) Set(email string, feature uint16, level uint8) error {
if !v.cache.Has(email) {
if err := v.loadFromStore(email); err != nil {
return err
Expand All @@ -92,11 +92,11 @@ func (v *_acl) Set(email string, feature uint16, level uint8) error {
return v.saveToStore(email)
}

func (v *_acl) Flush(email string) {
func (v *object) Flush(email string) {
v.cache.Flush(email)
}

func (v *_acl) loadFromStore(email string) error {
func (v *object) loadFromStore(email string) error {
access, err := v.store.FindACL(email)
if err != nil {
return errors.Wrap(err, errUserNotFound)
Expand All @@ -105,7 +105,7 @@ func (v *_acl) loadFromStore(email string) error {
return nil
}

func (v *_acl) saveToStore(email string) error {
func (v *object) saveToStore(email string) error {
access, err := v.cache.GetAll(email)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion acl/acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

func TestUnit_NewACL(t *testing.T) {
store := acl2.NewInMemoryStorage()
acl := acl2.NewACL(store, 3)
acl := acl2.New(store, 3)

email := "demo@example.com"

Expand Down
2 changes: 1 addition & 1 deletion acl/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ replace (
)

require (
go.osspkg.com/goppy/errors v0.3.0
go.osspkg.com/goppy/errors v0.3.1
go.osspkg.com/goppy/xtest v0.3.0
)

Expand Down
8 changes: 7 additions & 1 deletion app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pig: /var/run/simple.pid
```
level:
* 0 - error only
* 1 - + warning
* 2 - + info
Expand Down Expand Up @@ -73,6 +74,7 @@ func main() {
## HowTo

***Run the app***

```go
app.New()
.ConfigFile(<path to config file: string>, <config objects separate by comma: ...interface{}>)
Expand All @@ -85,12 +87,14 @@ app.New()
* Function that returns an object or interface

*All incoming dependencies will be injected automatically*

```go
type Simple1 struct{}
func NewSimple1(_ *log.Logger) *Simple1 { return &Simple1{} }
```

*Returns the interface*

```go
type Simple2 struct{}
type Simple2Interface interface{
Expand All @@ -102,7 +106,9 @@ func (s2 *Simple2) Get() string {
}
```

*If the object has the `Up(xc.Context) error` and `Down() error` methods, they will be called `Up(xc.Context) error` when the app starts, and `Down() error` when it finishes. This allows you to automatically start and stop routine processes inside the module*
*If the object has the `Up(xc.Context) error` and `Down() error` methods, they will be called `Up(xc.Context) error`
when the app starts, and `Down() error` when it finishes. This allows you to automatically start and stop routine
processes inside the module*

```go
var _ service.IServiceCtx = (*Simple3)(nil)
Expand Down
2 changes: 1 addition & 1 deletion app/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func (a *_app) prepareConfig(interactive bool) {
}
if len(a.configFilePath) > 0 {
// read config file
resolver := config.NewConfigResolve(a.resolvers...)
resolver := config.New(a.resolvers...)
if err = resolver.OpenFile(a.configFilePath); err != nil {
console.FatalIfErr(err, "open config file: %s", a.configFilePath)
}
Expand Down
4 changes: 0 additions & 4 deletions app/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ func TestUnit_EmptyDI(t *testing.T) {
xtest.NoError(t, c.Stop())
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

type SimpleString string

type SimpleDI1_A struct {
Expand Down Expand Up @@ -91,8 +89,6 @@ func (v *SimpleDI1_Service) Down() error {
return nil
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

func TestUnit_SimpleDI1(t *testing.T) {
c := app.NewContainer(xc.New())
xtest.NoError(t, c.Register(
Expand Down
12 changes: 6 additions & 6 deletions app/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ replace (

require (
go.osspkg.com/algorithms v1.3.1
go.osspkg.com/goppy/config v0.0.2
go.osspkg.com/goppy/console v0.3.1
go.osspkg.com/goppy/env v0.3.0
go.osspkg.com/goppy/errors v0.3.0
go.osspkg.com/goppy/config v0.0.3
go.osspkg.com/goppy/console v0.3.2
go.osspkg.com/goppy/env v0.3.1
go.osspkg.com/goppy/errors v0.3.1
go.osspkg.com/goppy/iosync v0.3.0
go.osspkg.com/goppy/syscall v0.3.0
go.osspkg.com/goppy/xc v0.3.0
go.osspkg.com/goppy/xlog v0.3.2
go.osspkg.com/goppy/xc v0.3.1
go.osspkg.com/goppy/xlog v0.3.3
go.osspkg.com/goppy/xtest v0.3.0
)

Expand Down
2 changes: 0 additions & 2 deletions app/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ const (
itUpedService objectRelationService = 2
)

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

type (
objectStorageItem struct {
Address string
Expand Down
14 changes: 7 additions & 7 deletions auth/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ replace (

require (
github.com/mailru/easyjson v0.7.7
go.osspkg.com/goppy/encryption v0.3.2
go.osspkg.com/goppy/errors v0.3.0
go.osspkg.com/goppy/ioutil v0.3.0
go.osspkg.com/goppy/encryption v0.3.3
go.osspkg.com/goppy/errors v0.3.1
go.osspkg.com/goppy/ioutil v0.3.1
go.osspkg.com/goppy/plugins v0.3.1
go.osspkg.com/goppy/random v0.3.0
go.osspkg.com/goppy/web v0.3.3
go.osspkg.com/goppy/web v0.3.4
go.osspkg.com/goppy/xtest v0.3.0
golang.org/x/oauth2 v0.17.0
)
Expand All @@ -36,9 +36,9 @@ require (
github.com/josharian/intern v1.0.0 // indirect
go.osspkg.com/goppy/iosync v0.3.0 // indirect
go.osspkg.com/goppy/syscall v0.3.0 // indirect
go.osspkg.com/goppy/xc v0.3.0 // indirect
go.osspkg.com/goppy/xlog v0.3.2 // indirect
go.osspkg.com/goppy/xnet v0.3.0 // indirect
go.osspkg.com/goppy/xc v0.3.1 // indirect
go.osspkg.com/goppy/xlog v0.3.3 // indirect
go.osspkg.com/goppy/xnet v0.3.1 // indirect
go.osspkg.com/static v1.4.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.32.0 // indirect
Expand Down
2 changes: 1 addition & 1 deletion auth/oauth/isp.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func oauth2ExchangeContext(
return errors.Wrapf(err, "exchange to oauth service")
}
client := srv.Client(ctx, tok)
resp, err := client.Get(uri) //nolint: bodyclose
resp, err := client.Get(uri) // nolint: bodyclose
if err != nil {
return errors.Wrapf(err, "client request to oauth service")
}
Expand Down
6 changes: 3 additions & 3 deletions auth/oauth/oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (v *OAuth) Request(name string) func(http.ResponseWriter, *http.Request) {
if err != nil {
return func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte(err.Error())) //nolint: errcheck
w.Write([]byte(err.Error())) // nolint: errcheck
}
}
return func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -79,15 +79,15 @@ func (v *OAuth) CallBack(name string, call CallBack) func(w http.ResponseWriter,
if err != nil {
return func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte(err.Error())) //nolint: errcheck
w.Write([]byte(err.Error())) // nolint: errcheck
}
}
return func(w http.ResponseWriter, r *http.Request) {
code := r.URL.Query().Get(p.AuthCodeKey())
u, err := p.Exchange(r.Context(), code)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte(err.Error())) //nolint: errcheck
w.Write([]byte(err.Error())) // nolint: errcheck
return
}
call(w, r, u)
Expand Down
2 changes: 1 addition & 1 deletion config/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type (
}
)

func NewConfigResolve(rs ...Resolver) *Config {
func New(rs ...Resolver) *Config {
return &Config{
blob: nil,
resolvers: rs,
Expand Down
2 changes: 1 addition & 1 deletion config/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ envs:
err := os.WriteFile(filename, []byte(data), 0755)
xtest.NoError(t, err)

res := config.NewConfigResolve(config.EnvResolver())
res := config.New(config.EnvResolver())

err = res.OpenFile(filename)
xtest.NoError(t, err)
Expand Down
Loading

0 comments on commit b02d8f4

Please sign in to comment.