start working on client component

This commit is contained in:
Helmut Merz 2023-06-29 22:36:26 +02:00
parent bed55a63a2
commit c6d5fafa7d
3 changed files with 25 additions and 3 deletions

15
client/client.go Normal file
View file

@ -0,0 +1,15 @@
package client
import (
"git.sr.ht/~cco/go-scopes/config"
"git.sr.ht/~cco/go-scopes/lib"
)
type Cfg struct {
*config.BaseCfg
Url string
}
func Send(act lib.Action) bool {
return true
}

View file

@ -2,6 +2,7 @@ package etc
import (
"git.sr.ht/~cco/go-scopes/app"
"git.sr.ht/~cco/go-scopes/client"
"git.sr.ht/~cco/go-scopes/config"
"git.sr.ht/~cco/go-scopes/lib"
"git.sr.ht/~cco/go-scopes/lib/action"
@ -36,10 +37,15 @@ func Config() lib.Config {
Port: ovr("8123", SERVER_PORT),
}
test_client := &client.Cfg{
BaseCfg: b("test-client", core.Start),
Url: ovr("http://localhost:8123", SERVER_URL),
}
test_rcvr := b("test-receiver", core.Start).
AddAction("demo", action.Base(AH_Receiver))
app_c.Add(config_c, server_c, test_rcvr)
app_c.Add(config_c, server_c, test_client, test_rcvr)
return app_c
}
@ -56,6 +62,7 @@ const (
LOGFILE = "logfile"
LOGLEVEL = "loglevel"
SERVER_PORT = "server_port"
SERVER_URL = "server_url"
)
// in a production scenario this should be put in a separate

View file

@ -18,12 +18,12 @@ func TestConfig(tb *tbase.T) {
t.Run("config", ConfigTest)
t.Run("send", SendTest)
t.TearDownApp()
t.AssertEqual(t.LogCount(true), 7)
t.AssertEqual(t.LogCount(true), 8)
}
func AppTest(t *testing.T) {
ctx := t.Ctx
t.AssertEqual(len(ctx.Services()), 4)
t.AssertEqual(len(ctx.Services()), 5)
}
func ConfigTest(t *testing.T) {