Example #1
0
File: manifold.go Project: bac/juju
// Manifold returns a Manifold that encapsulates the statushistorypruner worker.
func Manifold(config ManifoldConfig) dependency.Manifold {
	return dependency.Manifold{
		Inputs: []string{config.APICallerName},
		Start: func(context dependency.Context) (worker.Worker, error) {
			var apiCaller base.APICaller
			if err := context.Get(config.APICallerName, &apiCaller); err != nil {
				return nil, errors.Trace(err)
			}

			facade := statushistory.NewFacade(apiCaller)
			prunerConfig := Config{
				Facade:         facade,
				MaxHistoryTime: config.MaxHistoryTime,
				MaxHistoryMB:   config.MaxHistoryMB,
				PruneInterval:  config.PruneInterval,
				NewTimer:       config.NewTimer,
			}
			w, err := New(prunerConfig)
			if err != nil {
				return nil, errors.Trace(err)
			}
			return w, nil
		},
	}
}
Example #2
0
// Manifold returns a Manifold that encapsulates the statushistorypruner worker.
func Manifold(config ManifoldConfig) dependency.Manifold {
	return dependency.Manifold{
		Inputs: []string{config.APICallerName},
		Start: func(getResource dependency.GetResourceFunc) (worker.Worker, error) {
			var apiCaller base.APICaller
			if err := getResource(config.APICallerName, &apiCaller); err != nil {
				return nil, errors.Trace(err)
			}

			facade := statushistory.NewFacade(apiCaller)
			prunerConfig := Config{
				Facade:           facade,
				MaxLogsPerEntity: config.MaxLogsPerEntity,
				PruneInterval:    config.PruneInterval,
				NewTimer:         config.NewTimer,
			}
			w, err := New(prunerConfig)
			if err != nil {
				return nil, errors.Trace(err)
			}
			return w, nil
		},
	}
}