Browse Source

En cours de développement

master
losyme 5 months ago
parent
commit
55a95e9afe
  1. 1
      go.mod
  2. 2
      go.sum
  3. 9
      workers/config.go
  4. 10
      workers/pool.go

1
go.mod

@ -12,6 +12,7 @@ require (
forge.chapril.org/losyme/util v0.0.0-20220101202923-23640bbd8739
forge.chapril.org/losyme/uuid v0.0.0-20220101202925-b6817a6cc0bb
forge.chapril.org/losyme/zombie v0.0.0-20220120090528-44afcc0a838e
github.com/Showmax/go-fqdn v1.0.0
)
require (

2
go.sum

@ -20,3 +20,5 @@ forge.chapril.org/losyme/uuid v0.0.0-20220101202925-b6817a6cc0bb h1:Zn6GNf8b2uJ/
forge.chapril.org/losyme/uuid v0.0.0-20220101202925-b6817a6cc0bb/go.mod h1:AgvbvGzTkQkbiM+s9eVhvLUSHbA0V6N+q5oBFI2v0LA=
forge.chapril.org/losyme/zombie v0.0.0-20220120090528-44afcc0a838e h1:zNzPTCKxZBoZV1mB2R+Mt0qg4MDkIULnIxNQyIjhN9s=
forge.chapril.org/losyme/zombie v0.0.0-20220120090528-44afcc0a838e/go.mod h1:f2dCQZ+o+tk8hzWDapLPvqjiEF1QShkS19jOptvoYaM=
github.com/Showmax/go-fqdn v1.0.0 h1:0rG5IbmVliNT5O19Mfuvna9LL7zlHyRfsSvBPZmF9tM=
github.com/Showmax/go-fqdn v1.0.0/go.mod h1:SfrFBzmDCtCGrnHhoDjuvFnKsWjEQX/Q9ARZvOrJAko=

9
workers/config.go

@ -24,6 +24,7 @@ type Logger interface {
type Config struct {
PoolSize int
Model sdk.Model
Runner sdk.Runner
Logger Logger
}
@ -36,6 +37,12 @@ func WithPoolSize(poolSize int) ConfigOption {
}
}
func WithModel(model sdk.Model) ConfigOption {
return func(c *Config) {
c.Model = model
}
}
func WithRunner(runner sdk.Runner) ConfigOption {
return func(c *Config) {
c.Runner = runner
@ -68,7 +75,7 @@ func (c *Config) BuildWorkers() (*Workers, error) {
}
state := newState()
pool := newPool(c, "?", state)
pool := newPool(c, state)
supervisor := newSupervisor(c.PoolSize, c.Logger, pool)
ws := &Workers{

10
workers/pool.go

@ -11,6 +11,7 @@ import (
"forge.chapril.org/dune/sdk"
"forge.chapril.org/losyme/zombie"
"github.com/Showmax/go-fqdn"
)
type pool struct {
@ -23,9 +24,14 @@ type pool struct {
zombie *zombie.GWithContext
}
func newPool(cfg *Config, host string, state *state) *pool {
func newPool(cfg *Config, state *state) *pool {
fqdn, err := fqdn.FqdnHostname()
if err != nil {
fqdn = "?"
}
return &pool{
host: host,
host: fqdn,
runner: cfg.Runner,
logger: cfg.Logger,
state: state,

Loading…
Cancel
Save