Skip to content

Commit

Permalink
moved pkg from github.com/osspkg/goppy
Browse files Browse the repository at this point in the history
  • Loading branch information
markus621 committed Jul 1, 2024
1 parent d6b6b5f commit 278beec
Show file tree
Hide file tree
Showing 57 changed files with 106 additions and 104 deletions.
8 changes: 4 additions & 4 deletions app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"fmt"

"go.osspkg.com/x/app"
"go.osspkg.com/x/log"
xc "go.osspkg.com/x/context"
"go.osspkg.com/x/logx"
"go.osspkg.com/x/xc"
)

type (
Expand Down Expand Up @@ -60,7 +60,7 @@ func (s *Simple) Down(_ xc.Context) error {

func main() {
app.New().
Logger(log.Default()).
Logger(logx.Default()).
ConfigFile(
"./config.yaml",
Config{},
Expand Down Expand Up @@ -91,7 +91,7 @@ app.New()

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

*Returns the interface*
Expand Down
30 changes: 15 additions & 15 deletions app/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ package app
import (
"go.osspkg.com/x/config"
"go.osspkg.com/x/console"
"go.osspkg.com/x/context"
"go.osspkg.com/x/env"
"go.osspkg.com/x/log"
"go.osspkg.com/x/logx"
"go.osspkg.com/x/syscall"
"go.osspkg.com/x/xc"
)

type (
App interface {
Logger(log log.Logger) App
Logger(log logx.Logger) App
Modules(modules ...interface{}) App
ConfigResolvers(res ...config.Resolver) App
ConfigFile(filename string) App
Expand All @@ -36,15 +36,15 @@ type (
modules Modules
packages Container
logHandler *_log
log log.Logger
appContext context.Context
log logx.Logger
appContext xc.Context
exitFunc func(code int)
}
)

// New create application
func New() App {
ctx := context.New()
ctx := xc.New()
return &_app{
resolvers: make([]config.Resolver, 0, 2),
modules: Modules{},
Expand All @@ -56,7 +56,7 @@ func New() App {
}

// Logger setup logger
func (a *_app) Logger(l log.Logger) App {
func (a *_app) Logger(l logx.Logger) App {
a.log = l
return a
}
Expand Down Expand Up @@ -215,7 +215,7 @@ func (a *_app) prepareConfig(interactive bool) {
Format: "string",
})
if a.log == nil {
a.log = log.Default()
a.log = logx.Default()
}
a.logHandler.Handler(a.log)
}
Expand All @@ -240,7 +240,7 @@ func (a *_app) prepareConfig(interactive bool) {
// init logger
a.logHandler = newLog(appConfig.Log)
if a.log == nil {
a.log = log.Default()
a.log = logx.Default()
}
a.logHandler.Handler(a.log)
a.modules = a.modules.Add(
Expand All @@ -253,24 +253,24 @@ func (a *_app) prepareConfig(interactive bool) {
return resolver.Decode(c)
})
if err != nil {
a.log.WithFields(log.Fields{
a.log.WithFields(logx.Fields{
"err": err.Error(),
}).Fatalf("Decode config file")
}
a.modules = a.modules.Add(configs...)

if !interactive && len(a.pidFilePath) > 0 {
if err = syscall.Pid(a.pidFilePath); err != nil {
a.log.WithFields(log.Fields{
a.log.WithFields(logx.Fields{
"err": err.Error(),
"file": a.pidFilePath,
}).Fatalf("Create pid file")
}
}
}
a.modules = a.modules.Add(
func() log.Logger { return a.log },
func() context.Context { return a.appContext },
func() logx.Logger { return a.log },
func() xc.Context { return a.appContext },
)
}

Expand All @@ -287,7 +287,7 @@ func (a *_app) steps(up []step, wait func(bool), down []step) bool {
a.log.Infof(s.Message)
}
if err := s.Call(); err != nil {
a.log.WithFields(log.Fields{
a.log.WithFields(logx.Fields{
"err": err.Error(),
}).Errorf(s.Message)
erc++
Expand All @@ -302,7 +302,7 @@ func (a *_app) steps(up []step, wait func(bool), down []step) bool {
a.log.Infof(s.Message)
}
if err := s.Call(); err != nil {
a.log.WithFields(log.Fields{
a.log.WithFields(logx.Fields{
"err": err.Error(),
}).Errorf(s.Message)
erc++
Expand Down
10 changes: 5 additions & 5 deletions app/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import (
"reflect"

"go.osspkg.com/x/algorithms/graph/kahn"
"go.osspkg.com/x/context"
"go.osspkg.com/x/errors"
"go.osspkg.com/x/sync"
"go.osspkg.com/x/syncing"
"go.osspkg.com/x/xc"
)

type (
container struct {
kahn *kahn.Graph
srv *serviceTree
store *objectStorage
status sync.Switch
status syncing.Switch
}

Container interface {
Expand All @@ -32,12 +32,12 @@ type (
}
)

func NewContainer(ctx context.Context) Container {
func NewContainer(ctx xc.Context) Container {
return &container{
kahn: kahn.New(),
srv: newServiceTree(ctx),
store: newObjectStorage(),
status: sync.NewSwitch(),
status: syncing.NewSwitch(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"testing"

"go.osspkg.com/x/app"
xc "go.osspkg.com/x/context"
"go.osspkg.com/x/errors"
"go.osspkg.com/x/test"
"go.osspkg.com/x/xc"
)

func TestUnit_EmptyDI(t *testing.T) {
Expand Down
12 changes: 6 additions & 6 deletions app/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ replace (
go.osspkg.com/x/algorithms => ../algorithms
go.osspkg.com/x/config => ../config
go.osspkg.com/x/console => ../console
go.osspkg.com/x/context => ../context
go.osspkg.com/x/xc => ../xc
go.osspkg.com/x/env => ../env
go.osspkg.com/x/errors => ../errors
go.osspkg.com/x/log => ../log
go.osspkg.com/x/sync => ../sync
go.osspkg.com/x/logx => ../logx
go.osspkg.com/x/syncing => ../syncing
go.osspkg.com/x/syscall => ../syscall
go.osspkg.com/x/test => ../test
)
Expand All @@ -19,11 +19,11 @@ require (
go.osspkg.com/x/algorithms v0.5.0
go.osspkg.com/x/config v0.5.1
go.osspkg.com/x/console v0.5.1
go.osspkg.com/x/context v0.5.0
go.osspkg.com/x/xc v0.5.0
go.osspkg.com/x/env v0.5.0
go.osspkg.com/x/errors v0.5.0
go.osspkg.com/x/log v0.5.2
go.osspkg.com/x/sync v0.5.1
go.osspkg.com/x/logx v0.5.2
go.osspkg.com/x/syncing v0.5.1
go.osspkg.com/x/syscall v0.5.0
go.osspkg.com/x/test v0.5.0
)
Expand Down
10 changes: 5 additions & 5 deletions app/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ package app
import (
"os"

"go.osspkg.com/x/log"
"go.osspkg.com/x/logx"
)

type _log struct {
file *os.File
handler log.Logger
handler logx.Logger
conf LogConfig
}

Expand All @@ -25,15 +25,15 @@ func newLog(conf LogConfig) *_log {
return &_log{file: file, conf: conf}
}

func (v *_log) Handler(l log.Logger) {
func (v *_log) Handler(l logx.Logger) {
v.handler = l
v.handler.SetOutput(v.file)
v.handler.SetLevel(v.conf.Level)
switch v.conf.Format {
case "string":
v.handler.SetFormatter(log.NewFormatString())
v.handler.SetFormatter(logx.NewFormatString())
case "json":
v.handler.SetFormatter(log.NewFormatJSON())
v.handler.SetFormatter(logx.NewFormatJSON())
}
}

Expand Down
8 changes: 4 additions & 4 deletions app/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ package app
import (
"context"

xc "go.osspkg.com/x/context"
"go.osspkg.com/x/errors"
"go.osspkg.com/x/sync"
"go.osspkg.com/x/syncing"
"go.osspkg.com/x/xc"
)

type (
Expand Down Expand Up @@ -77,7 +77,7 @@ type (
}
serviceTree struct {
tree *treeItem
status sync.Switch
status syncing.Switch
ctx xc.Context
}
)
Expand All @@ -86,7 +86,7 @@ func newServiceTree(ctx xc.Context) *serviceTree {
return &serviceTree{
tree: nil,
ctx: ctx,
status: sync.NewSwitch(),
status: syncing.NewSwitch(),
}
}

Expand Down
3 changes: 0 additions & 3 deletions context/go.mod

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package aesgcm_test
import (
"testing"

"go.osspkg.com/x/encryption/aesgcm"
"go.osspkg.com/x/encrypt/aesgcm"
"go.osspkg.com/x/random"
"go.osspkg.com/x/test"
)
Expand Down
2 changes: 1 addition & 1 deletion encryption/go.mod → encrypt/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module go.osspkg.com/x/encryption
module go.osspkg.com/x/encrypt

go 1.20

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion encryption/pgp/pgp_test.go → encrypt/pgp/pgp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"crypto"
"testing"

"go.osspkg.com/x/encryption/pgp"
"go.osspkg.com/x/encrypt/pgp"
)

func TestUnit_PGP(t *testing.T) {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion encryption/x509/x509_test.go → encrypt/x509/x509_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"
"time"

"go.osspkg.com/x/encryption/x509"
"go.osspkg.com/x/encrypt/x509"
)

func TestUnit_X509(t *testing.T) {
Expand Down
12 changes: 6 additions & 6 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ use (
./app
./config
./console
./context
./domain
./encryption
./encrypt
./env
./errors
./graphics
./io
./log
./net
./ioutils
./logx
./network
./random
./routine
./sync
./syncing
./syscall
./test
./version
./xc
)
2 changes: 2 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
go.osspkg.com/x/sync v0.5.1 h1:3aTok1Sh6hZkD5QtC1Va8i1kGlNiZEADvJfQo/SIPQE=
go.osspkg.com/x/sync v0.5.1/go.mod h1:eFQ3C0NZtd2mu29VdN8cVjDy6S/Iy85Uw/Tlqq98rrc=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
Expand Down
2 changes: 1 addition & 1 deletion io/ascii.go → ioutils/ascii.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Use of this source code is governed by a BSD 3-Clause license that can be found in the LICENSE file.
*/

package io
package ioutils

import "bytes"

Expand Down
8 changes: 4 additions & 4 deletions io/encdec.go → ioutils/encdec.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
* Use of this source code is governed by a BSD 3-Clause license that can be found in the LICENSE file.
*/

package io
package ioutils

import (
"encoding/json"
"os"
"path/filepath"

"go.osspkg.com/x/errors"
"go.osspkg.com/x/sync"
"go.osspkg.com/x/syncing"
"gopkg.in/yaml.v3"
)

Expand All @@ -27,14 +27,14 @@ var (
type encoders struct {
enc map[string]func(v interface{}) ([]byte, error)
dec map[string]func([]byte, interface{}) error
mux sync.Lock
mux syncing.Lock
}

func newEncoders() *encoders {
return &encoders{
enc: make(map[string]func(v interface{}) ([]byte, error), 10),
dec: make(map[string]func([]byte, interface{}) error, 10),
mux: sync.NewLock(),
mux: syncing.NewLock(),
}
}

Expand Down
Loading

0 comments on commit 278beec

Please sign in to comment.