Пример #1
0
func New(registry *registry.Registry, events *event.EventBus, machine *machine.Machine, ttl, unitPrefix string, verifier *sign.SignatureVerifier) (*Agent, error) {
	ttldur, err := time.ParseDuration(ttl)
	if err != nil {
		return nil, err
	}

	state := NewState()
	mgr := systemd.NewSystemdManager(machine, unitPrefix)

	return &Agent{registry, events, machine, ttldur, unitPrefix, verifier, state, mgr, nil}, nil
}
Пример #2
0
func New(reg registry.Registry, eStream *registry.EventStream, mach *machine.Machine, ttl string, verifier *sign.SignatureVerifier) (*Agent, error) {
	ttldur, err := time.ParseDuration(ttl)
	if err != nil {
		return nil, err
	}

	mgr, err := systemd.NewSystemdManager(mach)
	if err != nil {
		return nil, err
	}

	state := NewState()
	eBus := event.NewEventBus()

	a := &Agent{reg, eStream, eBus, mach, ttldur, verifier, state, mgr, nil}

	hdlr := NewEventHandler(a)
	eBus.AddListener("agent", hdlr)

	return a, nil
}