Firebase load balancer
Go
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
.travis.yml
LICENSE
README.md
metadata.go
metadata_test.go
namespace.go
namespace_test.go
pool.go
pool_test.go
strategy.go

README.md

fireload


Build Status Coverage Status

A load balancer for multiple Firebase instances.

Installation

go get -u github.com/CloudCom/fireload

Usage

Import fireload

import "github.com/CloudCom/fireload"

Namespaces

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")
}

Pool

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)