func New(cfg config.Config) *Server { m := machine.New(cfg.BootId, cfg.PublicIP, cfg.Metadata()) m.RefreshState() regClient := etcd.NewClient(cfg.EtcdServers) regClient.SetConsistency(etcd.STRONG_CONSISTENCY) r := registry.New(regClient) eb := event.NewEventBus() eb.Listen() eventClient := etcd.NewClient(cfg.EtcdServers) eventClient.SetConsistency(etcd.STRONG_CONSISTENCY) es := registry.NewEventStream(eventClient) a, err := agent.New(r, eb, m, cfg.AgentTTL, cfg.UnitPrefix) if err != nil { //TODO: return this as an error object rather than panicking panic(err) } e := engine.New(r, eb, m) return &Server{a, e, m, r, eb, es} }
func New(cfg config.Config) *Server { m := machine.New(cfg.BootId, cfg.PublicIP, cfg.Metadata()) m.RefreshState() regClient := etcd.NewClient(cfg.EtcdServers) regClient.SetConsistency(etcd.STRONG_CONSISTENCY) r := registry.New(regClient) eb := event.NewEventBus() eb.Listen() eventClient := etcd.NewClient(cfg.EtcdServers) eventClient.SetConsistency(etcd.STRONG_CONSISTENCY) es := registry.NewEventStream(eventClient, r) var verifier *sign.SignatureVerifier if cfg.VerifyUnits { var err error verifier, err = sign.NewSignatureVerifierFromAuthorizedKeysFile(cfg.AuthorizedKeysFile) if err != nil { log.Errorln("Failed to get any key from authorized key file in verify_units mode:", err) verifier = sign.NewSignatureVerifier() } } a, err := agent.New(r, eb, m, cfg.AgentTTL, cfg.UnitPrefix, verifier) if err != nil { //TODO: return this as an error object rather than panicking panic(err) } e := engine.New(r, eb, m) return &Server{a, e, m, r, eb, es} }
func newMachineFromConfig(cfg config.Config) (*machine.CoreOSMachine, error) { state := machine.MachineState{ PublicIP: cfg.PublicIP, Metadata: cfg.Metadata(), Version: version.Version, } mach := machine.NewCoreOSMachine(state) mach.Refresh() if mach.State().ID == "" { return nil, errors.New("unable to determine local machine ID") } return mach, nil }