Skip to content

CloudCom/fireload

Repository files navigation

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)

Releases

No releases published

Packages

No packages published

Languages