当前位置: 首页>>代码示例>>Golang>>正文


Golang registry.New函数代码示例

本文整理汇总了Golang中github.com/coreos/fleet/registry.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了New函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: New

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}
}
开发者ID:jsdir,项目名称:fleet,代码行数:35,代码来源:server.go

示例2: getRegistry

// getRegistry initializes a connection to the Registry
func getRegistry() registry.Registry {
	tun := getTunnelFlag()

	machines := []string{globalFlags.Endpoint}
	client := etcd.NewClient(machines)

	if tun != "" {
		sshClient, err := ssh.NewSSHClient("core", tun, getChecker(), false)
		if err != nil {
			fmt.Fprintf(os.Stderr, "Failed initializing SSH client: %v\n", err)
			os.Exit(1)
		}

		dial := func(network, addr string) (net.Conn, error) {
			tcpaddr, err := net.ResolveTCPAddr(network, addr)
			if err != nil {
				return nil, err
			}
			return sshClient.DialTCP(network, nil, tcpaddr)
		}

		tr := http.Transport{
			Dial: dial,
			TLSClientConfig: &tls.Config{
				InsecureSkipVerify: true,
			},
		}

		client.SetTransport(&tr)
	}

	return registry.New(client, globalFlags.EtcdKeyPrefix)
}
开发者ID:paulczar,项目名称:fleet,代码行数:34,代码来源:fleetctl.go

示例3: getRegistry

func getRegistry(context *cli.Context) *registry.Registry {
	tun := getTunnelFlag(context)
	endpoint := context.GlobalString("endpoint")

	machines := []string{endpoint}
	client := etcd.NewClient(machines)

	if tun != "" {
		sshClient, err := ssh.NewSSHClient("core", tun)
		if err != nil {
			panic(err)
		}

		dial := func(network, addr string) (net.Conn, error) {
			tcpaddr, err := net.ResolveTCPAddr(network, addr)
			if err != nil {
				return nil, err
			}
			return sshClient.DialTCP(network, nil, tcpaddr)
		}

		tr := http.Transport{
			Dial: dial,
			TLSClientConfig: &tls.Config{
				InsecureSkipVerify: true,
			},
		}

		client.SetTransport(&tr)
	}

	return registry.New(client)
}
开发者ID:natacado,项目名称:fleet,代码行数:33,代码来源:cmd.go

示例4: getRegistry

func getRegistry() *registry.Registry {
	tun := getTunnelFlag()
	endpoint := getEndpointFlag()

	machines := []string{endpoint}
	client := etcd.NewClient(machines)

	if tun != "" {
		sshClient, err := ssh.NewSSHClient("core", tun, getChecker(), false)
		if err != nil {
			log.Fatalf("Failed initializing SSH client: %v", err)
		}

		dial := func(network, addr string) (net.Conn, error) {
			tcpaddr, err := net.ResolveTCPAddr(network, addr)
			if err != nil {
				return nil, err
			}
			return sshClient.DialTCP(network, nil, tcpaddr)
		}

		tr := http.Transport{
			Dial: dial,
			TLSClientConfig: &tls.Config{
				InsecureSkipVerify: true,
			},
		}

		client.SetTransport(&tr)
	}

	return registry.New(client)
}
开发者ID:nullstyle,项目名称:fleet,代码行数:33,代码来源:cmd.go

示例5: New

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}
}
开发者ID:josephyzhou,项目名称:fleet,代码行数:25,代码来源:server.go

示例6: NewRegistryClient

func NewRegistryClient(trans *http.Transport, endpoint, keyPrefix string, requestTimeout time.Duration) (API, error) {
	machines := []string{endpoint}
	client, err := etcd.NewClient(machines, *trans, requestTimeout)
	if err != nil {
		return nil, err
	}

	return registry.New(client, keyPrefix), nil
}
开发者ID:BillTheBest,项目名称:fleet,代码行数:9,代码来源:registry.go

示例7: NewRegistryClient

func NewRegistryClient(trans *http.Transport, endpoint, keyPrefix string) (API, error) {
	machines := []string{endpoint}
	client, err := etcd.NewClient(machines, *trans)
	if err != nil {
		return nil, err
	}

	return registry.New(client, keyPrefix), nil
}
开发者ID:Jitendrakry,项目名称:fleet,代码行数:9,代码来源:registry.go

示例8: New

func New(cfg config.Config) (*Server, error) {
	mach, err := newMachineFromConfig(cfg)
	if err != nil {
		return nil, err
	}

	mgr, err := systemd.NewSystemdUnitManager(systemd.DefaultUnitsDirectory)
	if err != nil {
		return nil, err
	}

	eClient, err := etcd.NewClient(cfg.EtcdServers, http.Transport{})
	if err != nil {
		return nil, err
	}

	reg := registry.New(eClient, cfg.EtcdKeyPrefix)

	a, err := newAgentFromConfig(mach, reg, cfg, mgr)
	if err != nil {
		return nil, err
	}

	e := engine.New(reg, mach)

	sStream := systemd.NewEventStream(mgr)

	rStream, err := registry.NewEventStream(eClient, reg)
	if err != nil {
		return nil, err
	}

	aHandler := agent.NewEventHandler(a)
	eHandler := engine.NewEventHandler(e)

	eBus := event.NewEventBus()
	eBus.AddListener("engine", eHandler)
	eBus.AddListener("agent", aHandler)

	listeners, err := activation.Listeners(false)
	if err != nil {
		return nil, err
	}

	mux := api.NewServeMux(reg)
	for _, f := range listeners {
		go http.Serve(f, mux)
	}

	return &Server{a, e, rStream, sStream, eBus, mach, nil}, nil
}
开发者ID:Jitendrakry,项目名称:fleet,代码行数:51,代码来源:server.go

示例9: newEngineFromConfig

func newEngineFromConfig(mach *machine.Machine, cfg config.Config) (*engine.Engine, error) {
	regClient := etcd.NewClient(cfg.EtcdServers)
	regClient.SetConsistency(etcd.STRONG_CONSISTENCY)
	reg := registry.New(regClient, cfg.EtcdKeyPrefix)

	eClient := etcd.NewClient(cfg.EtcdServers)
	eClient.SetConsistency(etcd.STRONG_CONSISTENCY)
	eStream, err := registry.NewEventStream(eClient, reg)
	if err != nil {
		return nil, err
	}

	return engine.New(reg, eStream, mach), nil
}
开发者ID:rswart,项目名称:fleet,代码行数:14,代码来源:server.go

示例10: newAgentFromConfig

func newAgentFromConfig(mach machine.Machine, cfg config.Config, mgr unit.UnitManager) (*agent.Agent, error) {
	regClient := newEtcdClientFromConfig(cfg)
	reg := registry.New(regClient, cfg.EtcdKeyPrefix)

	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()
		}
	}

	return agent.New(mgr, reg, mach, cfg.AgentTTL, verifier)
}
开发者ID:paulczar,项目名称:fleet,代码行数:16,代码来源:server.go

示例11: getRegistryClient

func getRegistryClient() (client.API, error) {
	var dial func(string, string) (net.Conn, error)
	tun := getTunnelFlag()
	if tun != "" {
		sshClient, err := ssh.NewSSHClient(globalFlags.SSHUserName, tun, getChecker(), false)
		if err != nil {
			return nil, fmt.Errorf("failed initializing SSH client: %v", err)
		}

		dial = func(network, addr string) (net.Conn, error) {
			tcpaddr, err := net.ResolveTCPAddr(network, addr)
			if err != nil {
				return nil, err
			}
			return sshClient.DialTCP(network, nil, tcpaddr)
		}
	}

	tlsConfig, err := etcd.ReadTLSConfigFiles(globalFlags.EtcdCAFile, globalFlags.EtcdCertFile, globalFlags.EtcdKeyFile)
	if err != nil {
		return nil, err
	}

	trans := &http.Transport{
		Dial:            dial,
		TLSClientConfig: tlsConfig,
	}

	timeout := time.Duration(globalFlags.RequestTimeout*1000) * time.Millisecond
	machines := []string{globalFlags.Endpoint}
	eClient, err := etcd.NewClient(machines, trans, timeout)
	if err != nil {
		return nil, err
	}

	reg := registry.New(eClient, globalFlags.EtcdKeyPrefix)

	if msg, ok := checkVersion(reg); !ok {
		stderr(msg)
	}

	return &client.RegistryClient{reg}, nil
}
开发者ID:jcderr,项目名称:fleet,代码行数:43,代码来源:fleetctl.go

示例12: New

func New(cfg config.Config) (*Server, error) {
	mach, err := newMachineFromConfig(cfg)
	if err != nil {
		return nil, err
	}

	mgr, err := systemd.NewSystemdUnitManager(systemd.DefaultUnitsDirectory)
	if err != nil {
		return nil, err
	}

	eClient := etcd.NewClient(cfg.EtcdServers)

	reg := registry.New(eClient, cfg.EtcdKeyPrefix)

	a, err := newAgentFromConfig(mach, reg, cfg, mgr)
	if err != nil {
		return nil, err
	}

	e := engine.New(reg, mach)

	sStream := systemd.NewEventStream(mgr)

	rStream, err := registry.NewEventStream(eClient, reg)
	if err != nil {
		return nil, err
	}

	aHandler := agent.NewEventHandler(a)
	eHandler := engine.NewEventHandler(e)

	eBus := event.NewEventBus()
	eBus.AddListener("engine", eHandler)
	eBus.AddListener("agent", aHandler)

	return &Server{a, e, rStream, sStream, eBus, mach, nil}, nil
}
开发者ID:johnmontero,项目名称:fleet,代码行数:38,代码来源:server.go

示例13: newAgentFromConfig

func newAgentFromConfig(mach *machine.Machine, cfg config.Config) (*agent.Agent, error) {
	regClient := etcd.NewClient(cfg.EtcdServers)
	regClient.SetConsistency(etcd.STRONG_CONSISTENCY)
	reg := registry.New(regClient, cfg.EtcdKeyPrefix)

	eClient := etcd.NewClient(cfg.EtcdServers)
	eClient.SetConsistency(etcd.STRONG_CONSISTENCY)
	eStream, err := registry.NewEventStream(eClient, reg)
	if err != nil {
		return nil, err
	}

	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()
		}
	}

	return agent.New(reg, eStream, mach, cfg.AgentTTL, verifier)
}
开发者ID:rswart,项目名称:fleet,代码行数:24,代码来源:server.go

示例14: newRegistryEventStreamFromConfig

func newRegistryEventStreamFromConfig(cfg config.Config) (*registry.EventStream, error) {
	eClient := newEtcdClientFromConfig(cfg)
	reg := registry.New(eClient, cfg.EtcdKeyPrefix)
	return registry.NewEventStream(eClient, reg)
}
开发者ID:paulczar,项目名称:fleet,代码行数:5,代码来源:server.go

示例15: newEngineFromConfig

func newEngineFromConfig(mach machine.Machine, cfg config.Config) (*engine.Engine, error) {
	regClient := newEtcdClientFromConfig(cfg)
	reg := registry.New(regClient, cfg.EtcdKeyPrefix)
	return engine.New(reg, mach), nil
}
开发者ID:paulczar,项目名称:fleet,代码行数:5,代码来源:server.go


注:本文中的github.com/coreos/fleet/registry.New函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。