A load balancer for multiple Firebase instances.
go get -u github.com/CloudCom/fireload
Import fireload
import "github.com/CloudCom/fireload"
Creating a namespace:
instance1 := fireload.NewNamespace(“https://foo.firebaseIO.com”)
instance2 := fireload.NewNamespace(“https://bar.firebaseIO.com”)
You can also set/get Metadata on namespaces:
instance1.Metadata.Set(“awesome”, true)
instance1.Metadata.Set("secret", "very very secret")
instance2.Metadata.Set(“secret”, “my-awesome-secret”)
if secret, ok := instance2.Metdata.Get("awesome"); !ok {
println("instance2 is not awesome")
}
Creating a pool:
pool, err := fireload.NewPool(instance1, instance2)
if err != nil {
log.Fatal(err)
}
Pools allow you to specify the selection strategy used when retrieving a Namespace.
- Random (default)
- RoundRobin
pool.SetStrategy(fireload.StrategyRoundRobin)
Getting a namespace and using it:
namespace := pool.Next()
f := firego.New(namespace.Domain)