hipache

package
v0.0.0-...-9f1a7a8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2018 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package hipache provides a router implementation that store routes in Redis, as specified by Hipache (https://github.com/dotcloud/hipache).

It does not provide any exported type, in order to use the router, you must import this package and get the router instance using the function router.Get.

In order to use this router, you need to define the "routers:<name>:type = hipache" or "routers:<name>:type = planb" in your config.

Example
package main

import (
	"fmt"
	"net/url"

	"github.com/tsuru/tsuru/router"
	_ "github.com/tsuru/tsuru/router/hipache"
	"github.com/tsuru/tsuru/router/routertest"
)

func main() {
	router, err := router.Get("hipache")
	if err != nil {
		panic(err)
	}
	err = router.AddBackend(routertest.FakeApp{Name: "myapp"})
	if err != nil {
		panic(err)
	}
	u, err := url.Parse("http://10.10.10.10:8080")
	if err != nil {
		panic(err)
	}
	err = router.AddRoutes("myapp", []*url.URL{u})
	if err != nil {
		panic(err)
	}
	addr, _ := router.Addr("myapp")
	fmt.Println("Please access:", addr)
	err = router.RemoveRoutes("myapp", []*url.URL{u})
	if err != nil {
		panic(err)
	}
	err = router.RemoveBackend("myapp")
	if err != nil {
		panic(err)
	}
}
Output:

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL