rename package common to lib

This commit is contained in:
Helmut Merz 2023-06-04 09:43:31 +02:00
parent d9e109e3a5
commit 2f1efc9731
6 changed files with 25 additions and 25 deletions

View file

@ -4,7 +4,7 @@ import (
"os"
"strings"
"git.sr.ht/~cco/go-scopes/common"
"git.sr.ht/~cco/go-scopes/lib"
)
type Cfg struct {
@ -12,34 +12,34 @@ type Cfg struct {
ConfigFormat string
}
func Start(ctx common.Context) {
func Start(ctx lib.Context) {
}
// definitions
type Base struct {
name string
starter common.StartFct
children []common.Config
starter lib.StartFct
children []lib.Config
}
func (cfg *Base) Name() string {
return cfg.name
}
func (cfg *Base) Starter() common.StartFct {
func (cfg *Base) Starter() lib.StartFct {
return cfg.starter
}
func (cfg *Base) Children() []common.Config {
func (cfg *Base) Children() []lib.Config {
return cfg.children
}
func (cfg *Base) Add(child common.Config) {
func (cfg *Base) Add(child lib.Config) {
cfg.children = append(cfg.children, child)
}
func MakeBase(name string, starter common.StartFct) *Base {
func MakeBase(name string, starter lib.StartFct) *Base {
return &Base{
name: name,
starter: starter,

View file

@ -2,11 +2,11 @@ package etc
import (
"git.sr.ht/~cco/go-scopes"
"git.sr.ht/~cco/go-scopes/common"
"git.sr.ht/~cco/go-scopes/config"
"git.sr.ht/~cco/go-scopes/lib"
)
func Config() common.Config {
func Config() lib.Config {
ovr := Overrides().Use
b := config.MakeBase
cfg := scopes.Cfg{

View file

@ -1,4 +1,4 @@
package common
package lib
import (
stdlib_context "context"

View file

@ -6,8 +6,8 @@ import (
"os/signal"
"syscall"
"git.sr.ht/~cco/go-scopes/common"
"git.sr.ht/~cco/go-scopes/config"
"git.sr.ht/~cco/go-scopes/lib"
)
type Cfg struct {
@ -16,11 +16,11 @@ type Cfg struct {
Home string
}
func Start(ctx common.Context) {
common.RunCtx(ctx, start)
func Start(ctx lib.Context) {
lib.RunCtx(ctx, start)
}
func start(ctx common.Context) {
func start(ctx lib.Context) {
defer ctx.Stop()
for _, cfg := range ctx.Config().Children() {
cctx := ctx.ChildContext(cfg)
@ -34,7 +34,7 @@ func start(ctx common.Context) {
}
}
func step(ctx common.Context, sig <-chan os.Signal) bool {
func step(ctx lib.Context, sig <-chan os.Signal) bool {
select {
case <-sig:
fmt.Println("interrupted")
@ -54,8 +54,8 @@ func step(ctx common.Context, sig <-chan os.Signal) bool {
// definitions
func RunApp(cfg common.Config) {
ctx := common.AppContext(cfg)
func RunApp(cfg lib.Config) {
ctx := lib.AppContext(cfg)
cfg.Starter()(ctx)
ctx.WaitGroup().Wait()
}

View file

@ -9,10 +9,10 @@ import (
"time"
"git.sr.ht/~cco/go-scopes"
"git.sr.ht/~cco/go-scopes/common"
"git.sr.ht/~cco/go-scopes/lib"
)
func Start(ctx common.Context) {
func Start(ctx lib.Context) {
scopes.Start(ctx)
}
@ -22,7 +22,7 @@ type Map map[string]interface{}
type T struct {
Base *testing.T
Ctx common.Context
Ctx lib.Context
}
func MakeT(tbase *testing.T) *T {
@ -36,9 +36,9 @@ func SetUp(tbase *testing.T) *T {
return t
}
func SetUpApp(tbase *testing.T, cfg common.Config) *T {
func SetUpApp(tbase *testing.T, cfg lib.Config) *T {
t := SetUp(tbase)
t.Ctx = common.AppContext(cfg)
t.Ctx = lib.AppContext(cfg)
cfg.Starter()(t.Ctx)
time.Sleep(100 * time.Millisecond)
return t

View file

@ -2,12 +2,12 @@ package etc
import (
"git.sr.ht/~cco/go-scopes"
"git.sr.ht/~cco/go-scopes/common"
"git.sr.ht/~cco/go-scopes/config"
"git.sr.ht/~cco/go-scopes/lib"
"git.sr.ht/~cco/go-scopes/testing"
)
func Config() common.Config {
func Config() lib.Config {
ovr := Overrides().Use
b := config.MakeBase
cfg := scopes.Cfg{