mirror of https://github.com/docker/docs.git
scheduler: Pass the strategy and filters as a creation argument.
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
6585d4cfb6
commit
0577135ea9
|
|
@ -18,11 +18,11 @@ type Scheduler struct {
|
|||
filters []filter.Filter
|
||||
}
|
||||
|
||||
func NewScheduler(cluster *libcluster.Cluster) *Scheduler {
|
||||
func NewScheduler(cluster *libcluster.Cluster, strategy strategy.PlacementStrategy, filters []filter.Filter) *Scheduler {
|
||||
return &Scheduler{
|
||||
cluster: cluster,
|
||||
strategy: &strategy.RandomPlacementStrategy{},
|
||||
filters: []filter.Filter{},
|
||||
strategy: strategy,
|
||||
filters: filters,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import (
|
|||
"github.com/docker/libcluster"
|
||||
"github.com/docker/libcluster/api"
|
||||
"github.com/docker/libcluster/scheduler"
|
||||
"github.com/docker/libcluster/scheduler/filter"
|
||||
"github.com/docker/libcluster/scheduler/strategy"
|
||||
)
|
||||
|
||||
type logHandler struct {
|
||||
|
|
@ -39,7 +41,9 @@ func main() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
c.Events(&logHandler{})
|
||||
s := scheduler.NewScheduler(c)
|
||||
s := scheduler.NewScheduler(c, &strategy.RandomPlacementStrategy{}, []filter.Filter{})
|
||||
|
||||
log.Fatal(api.ListenAndServe(c, s, ":4243"))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue