All Projects → ereyes01 → firebase

ereyes01 / firebase

Licence: MIT License
Firebase Go REST SDK

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to firebase

fridgefm-radio-core
Simple lightweight package for creating your own radio station via NodeJS heavily inspired by Shoutcast and Icecast.
Stars: ✭ 32 (+45.45%)
Mutual labels:  stream
cthulhu
Cthulhu is a simple python CLI application that streams torrents directly from various sources.
Stars: ✭ 26 (+18.18%)
Mutual labels:  stream
laav
Asynchronous Audio / Video Library for H264 / MJPEG / OPUS / AAC / MP2 encoding, transcoding, recording and streaming from live sources
Stars: ✭ 50 (+127.27%)
Mutual labels:  stream
irc-tts
Broadcast your IRC channel via a text-to-speech webserver
Stars: ✭ 14 (-36.36%)
Mutual labels:  stream
exile
Alternative to ports for running external programs. It provides back-pressure, non-blocking io, and solves port related issues
Stars: ✭ 74 (+236.36%)
Mutual labels:  stream
moestreamer
macOS menubar music player
Stars: ✭ 17 (-22.73%)
Mutual labels:  stream
live-stream-media-source-extensions
Live stream h264 encoded mp4 video on media source extensions using ffmpeg, node.js, socket.io, and express. Works in chrome, firefox, safari, and android. Not iOS compatible. Work has moved to mse-live-player repo =>
Stars: ✭ 24 (+9.09%)
Mutual labels:  stream
parallel stream
A parallelized stream implementation for Elixir
Stars: ✭ 86 (+290.91%)
Mutual labels:  stream
hipipe
Super fast C++17 data transformation pipeline (with Python interface).
Stars: ✭ 16 (-27.27%)
Mutual labels:  stream
evry
Split STDIN stream and execute specified command every N lines/seconds.
Stars: ✭ 61 (+177.27%)
Mutual labels:  stream
react-webrtc-chat
React WebRTC chat
Stars: ✭ 39 (+77.27%)
Mutual labels:  stream
node-jstream
Continuously reads in JSON and outputs Javascript objects.
Stars: ✭ 13 (-40.91%)
Mutual labels:  stream
lazy-arr
Arrays that look just like regular JavaScript arrays, but are computed lazily.
Stars: ✭ 67 (+204.55%)
Mutual labels:  stream
wise-river
Object streaming the way it should be.
Stars: ✭ 33 (+50%)
Mutual labels:  stream
cpsfy
🚀 Tiny goodies for Continuation-Passing-Style functions, fully tested
Stars: ✭ 58 (+163.64%)
Mutual labels:  stream
rxjava2-http
Transmit RxJava2 Flowable over http with non-blocking backpressure
Stars: ✭ 19 (-13.64%)
Mutual labels:  stream
reactive-rs
Streams and broadcasts: functional reactive programming in Rust.
Stars: ✭ 28 (+27.27%)
Mutual labels:  stream
simple-concat
Super-minimalist version of `concat-stream`. Less than 15 lines!
Stars: ✭ 21 (-4.55%)
Mutual labels:  stream
pv
Unix Pipe Viewer (pv) utility in Node.js
Stars: ✭ 20 (-9.09%)
Mutual labels:  stream
youtube-play
🎵 A command-line utility which streams music from YouTube
Stars: ✭ 47 (+113.64%)
Mutual labels:  stream

Go Firebase

NOTE: This repo is in maintenance mode. If you're developing a new application, you should take a look at Google's official Firebase bindings. As of June 2020, this code is still stable and being used in production for real products. Maintenance / bug fixing will still be done if any is needed.

Helper library for invoking the Firebase REST API from your Go program. Supports the following operations:

  • Read and write values using Firebase's REST API operations
  • Stream updates to a Firebase path via the SSE / Event Source protocol
  • Use native Go types/structs in all Firebase operations
  • Server-side timestamps that are automatically converted into native Go times
  • Read and modify security rules

My starting point was the great work of cosn and JustinTulloss. Most of the code has since been refactored, and comprehensive unit tests that do not call out to the network have been added. Also, support for streaming via SSE / Event Source from Firebase has been added.

Please star on Github if you find this library useful! Thanks!

Build Status

Circle CI

Reference Documentation

GoDoc

Installation

  • Setup your GOPATH and workspace. If you are new to Go and you're not sure how to do this, read How to Write Go Code.
  • Dowload the package:
go get -u -t github.com/ereyes01/firebase

Run the Tests

  • To run the tests:
go test -race github.com/ereyes01/firebase

Usage

The usage examples below will use the sample Dinosaur Facts Firebase used in the REST tutorial

client := firebase.NewClient("https://dinosaur-facts.firebaseio.com", "", nil)

Suppose we have a struct defined that matches each entry in the dinosaurs/ path of this firebase. Our struct might be declared as follows:

type Dinosaur struct {
	Appeared int
	Height   float64
	Length   float64
	Order    string
	Vanished int
	Weight   float64
}

We could retrieve the lambeosarus record as follows:

var dino Dinosaur

err := client.Child("dinosaurs/lambeosaurus").Value(&dino)

We could query dinosaurs whose scores are greater than 50 as follows:

dinoScores := make(map[string]int)

err := client.Child("scores").OrderBy("$value").StartAt(50).Value(&dinoScores)

If I wanted to create a new dinosaur score (NOTE: the permissions of this firebase do not allow this), we could try:

value, err := client.Child("scores").Set("velociraptor", 500, nil)

We of course, don't have permissions to write to this Firebase. The error you'd get back should be:

Permission denied

Create your own free test Firebase and feel free to experiment with writing values!

Now suppose we wanted to watch changes to the Triceratops dinosaur in real-time. This, of course, will be a boring example because Triceratops will probably never change. However, this sample demonstrates how you would stream changes to a Firebase path in real-time (and stops streaming after 10 seconds):

    stop := make(chan bool)
	go func() {
		<-time.After(10 * time.Second)
		close(stop)
	}()

    // this helps convert incoming events into Dinosaur objects
    dinoParser := func(path string, data []byte) (interface{}, error) {
		var dino *Dinosaur
		err := json.Unmarshal(data, &dino)
		return dino, err
	}

	events, err := client.Child("dinosaurs/triceratops").Watch(dinoParser, stop)
	if err != nil {
		log.Fatal(err)
	}

	for event := range events {
		if event.Error != nil {
			log.Println("Stream error:", event.Error)
            continue
		}

		if event.UnmarshallerError != nil {
			log.Println("Malformed event:" event.UnmarshallerError)
            continue
		}

		newTriceratops := event.Resource.(*Dinosaur)
	}

The code above will yield a stream of Go Dinosaur objects (or rather, pointers to them). The magic is in the dinoParser callback. This function (passed to Watch) tells the watcher how to parse the json payload of the incoming events- in this case as Dinosaur pointers. When the streaming connection is closed, the events channel also closes.

When you watch a Firebase location, you'll get back an initial event showing the state of the location as it was when you started watching it. Thereafter, you will receive an event when a change happens that matches your criteria, or when some place in the location stopped matching your criteria. This can be a little confusing at first, especially when you combine queries with watching resources. It's just the way Firebase watching of resources works.

You can read more about this behavior in my Stack Overflow question and the subsequent discussion with one of the Firebase dudes.

Please see the Godoc reference for a guide to the code and a more detailed list of operations. Also, please familiarize yourself with Firebase's REST API capabilities before trying anything with this library.

Please open issues for any bugs or suggestions you may have, or send me a PR. Thanks!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].