示例#1
0
func MakeServer(url string) engine.Server {
	s, err := engine.NewServer(UID("server"), url)
	if err != nil {
		panic(err)
	}
	return *s
}
示例#2
0
文件: server.go 项目: vulcand/vulcand
func (cmd *Command) upsertServerAction(c *cli.Context) error {
	s, err := engine.NewServer(c.String("id"), c.String("url"))
	if err != nil {
		return err
	}
	if err := cmd.client.UpsertServer(engine.BackendKey{Id: c.String("backend")}, *s, c.Duration("ttl")); err != nil {
		return err
	}
	cmd.printOk("server upserted")
	return nil
}
示例#3
0
func (r *Registry) RegisterServer() error {
	s, err := engine.NewServer(r.serverID, r.url)

	if err != nil {
		return err
	}

	return r.client.UpsertServer(
		engine.BackendKey{Id: r.backendID},
		*s,
		r.ttl,
	)
}
示例#4
0
文件: router.go 项目: pedrosnk/tsuru
func (r *vulcandRouter) AddRoutes(name string, addresses []*url.URL) error {
	usedName, err := router.Retrieve(name)
	if err != nil {
		return err
	}
	for _, addr := range addresses {
		serverKey := engine.ServerKey{
			Id:         r.serverName(addr.String()),
			BackendKey: engine.BackendKey{Id: r.backendName(usedName)},
		}
		server, err := engine.NewServer(serverKey.Id, addr.String())
		if err != nil {
			return &router.RouterError{Err: err, Op: "add-route"}
		}
		err = r.client.UpsertServer(serverKey.BackendKey, *server, engine.NoTTL)
		if err != nil {
			return &router.RouterError{Err: err, Op: "add-route"}
		}
	}
	return nil
}
示例#5
0
文件: router.go 项目: pedrosnk/tsuru
func (r *vulcandRouter) AddRoute(name string, address *url.URL) error {
	usedName, err := router.Retrieve(name)
	if err != nil {
		return err
	}
	serverKey := engine.ServerKey{
		Id:         r.serverName(address.String()),
		BackendKey: engine.BackendKey{Id: r.backendName(usedName)},
	}
	if found, _ := r.client.GetServer(serverKey); found != nil {
		return router.ErrRouteExists
	}
	server, err := engine.NewServer(serverKey.Id, address.String())
	if err != nil {
		return &router.RouterError{Err: err, Op: "add-route"}
	}
	err = r.client.UpsertServer(serverKey.BackendKey, *server, engine.NoTTL)
	if err != nil {
		return &router.RouterError{Err: err, Op: "add-route"}
	}
	return nil
}