Browse Source

En cours de développement

master
losyme 7 months ago
parent
commit
625354bc35
  1. 6
      workers/config.go
  2. 8
      workers/pool.go
  3. 8
      workers/worker.go
  4. 2
      workers/workers.go

6
workers/config.go

@ -12,7 +12,7 @@ const _maxPoolSize = 20
type Config struct {
PoolSize int
Hostname string
Host string
Runner Runner
Logger Logger
}
@ -24,8 +24,8 @@ func (cfg *Config) validate() error {
cfg.PoolSize = _maxPoolSize
}
if cfg.Hostname == "" {
cfg.Hostname = "?"
if cfg.Host == "" {
cfg.Host = "?"
}
if cfg.Logger == nil {

8
workers/pool.go

@ -9,7 +9,7 @@ package workers
import "sync"
type pool struct {
hostname string
host string
runner Runner
dashboard *dashboard
logger Logger
@ -17,9 +17,9 @@ type pool struct {
mutex sync.Mutex
}
func newPool(hostname string, runner Runner, dashboard *dashboard, logger Logger) *pool {
func newPool(host string, runner Runner, dashboard *dashboard, logger Logger) *pool {
return &pool{
hostname: hostname,
host: host,
runner: runner,
dashboard: dashboard,
logger: logger,
@ -35,7 +35,7 @@ func (p *pool) size() int {
}
func (p *pool) startOneWorker(stoppedCh chan<- string) {
worker, err := newWorker(p.hostname, p.runner, p.dashboard, p.logger)
worker, err := newWorker(p.host, p.runner, p.dashboard, p.logger)
if err != nil {
p.logger.Error("Unable to create a worker", "reason", err) //:::::::::::::::::::::::::::::::::::::::::::::::::::
return

8
workers/worker.go

@ -17,7 +17,7 @@ import (
type worker struct {
id string
hostname string
host string
runner Runner
dashboard *dashboard
logger Logger
@ -25,7 +25,7 @@ type worker struct {
closeOnce sync.Once
}
func newWorker(hostname string, runner Runner, dashboard *dashboard, logger Logger) (*worker, error) {
func newWorker(host string, runner Runner, dashboard *dashboard, logger Logger) (*worker, error) {
id := uuid.New()
logger, err := logger.Clone(id, "worker")
@ -35,7 +35,7 @@ func newWorker(hostname string, runner Runner, dashboard *dashboard, logger Logg
w := &worker{
id: id,
hostname: hostname,
host: host,
runner: runner,
dashboard: dashboard,
logger: logger,
@ -102,7 +102,7 @@ func (w *worker) maybeRunJob() (duration time.Duration) {
job.Succeeded()
}
job.Result.Host = w.hostname // AFINIR
job.Result.Host = w.host
job.Result.Worker = w.id
if job, err := w.runner.Model().UpdateJob(job); err == nil {

2
workers/workers.go

@ -40,7 +40,7 @@ func New(cfg *Config) (*Workers, error) {
}
dashboard := newDashboard()
pool := newPool(cfg.Hostname, cfg.Runner, dashboard, cfg.Logger)
pool := newPool(cfg.Host, cfg.Runner, dashboard, cfg.Logger)
supervisor := newSupervisor(cfg.PoolSize, pool)
ws := &Workers{

Loading…
Cancel
Save