Exemple #1
0
func MakeServer(url string) engine.Server {
	s, err := engine.NewServer(UID("server"), url)
	if err != nil {
		panic(err)
	}
	return *s
}
Exemple #2
0
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
}
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,
	)
}
Exemple #4
0
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
}
Exemple #5
0
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
}