示例#1
0
// Inserts or updates a routes in etcd.
func (c *Client) Upsert(r *eskip.Route) error {
	if r.Id == "" {
		return missingRouteId
	}

	_, err := c.etcd.Set(c.routesRoot+"/"+r.Id, r.String(), 0)
	return err
}
示例#2
0
// generate weak random id for a route if
// it doesn't have one.
func ensureId(r *eskip.Route) error {
	if r.Id != "" {
		return nil
	}

	// using this to avoid adding a new dependency.
	id, err := flowid.NewFlowId(randomIdLength)
	if err != nil {
		return err
	}

	// replace characters that are not allowed
	// for eskip route ids.
	id = routeIdRx.ReplaceAllString(id, "x")
	r.Id = "route" + id
	return nil
}
示例#3
0
func (c *Client) etcdSet(r *eskip.Route) error {
	_, err := c.etcdRequest("PUT", c.routesRoot+"/"+r.Id, r.String())
	return err
}
示例#4
0
文件: write.go 项目: zalando/skipper
func routesDiffer(left, right *eskip.Route) bool {
	return left.String() != right.String()
}