Git Product home page Git Product logo

go-bqstreamer's Introduction

BigQuery Streamer GoDoc Build Status Coverage Status

Stream insert data into BigQuery fast and concurrently, using InsertAll().

Features

  • Inserts multiple rows in bulk.
  • Uses configurable multiple workers (i.e. goroutines) to queue and insert rows.
  • Production ready, and thoroughly tested. We - at Rounds - are using it in our data gathering workflow.
  • BigQuery errors are sent to a unified channel so you can read and decide how to handle them.

Getting Started

  1. Install Go, version should be at least 1.3. We recommend using gvm to manage your Go versions.
  2. Execute go get -t ./... to download all necessary packages.
  3. Acquire Google OAuth2/JWT credentials, so you can connect to BigQuery.
  4. Copy and run one of the examples: MultiStreamer and Streamer.

How Does It Work?

There are two types you can use: Streamer and MultiStreamer.

Streamer

A Streamer is a single worker which reads rows, queues them, and inserts them (also called "flushing") in bulk into BigQuery once a certain threshold is reached. Thresholds can be either an amount of rows queued, or based on time - inserting once a certain time has passed.

This provides flush control, inserting in set sizes and quickly enough. Please note Google has quota policies on size and frequency of inserts.

In addition, the Streamer knows to handle BigQuery server erros (HTTP 500 and the like), and attempts to retry insertions several times on such failures.

It also sends errors on an error channel, which can be read an handled.

MultiStreamer

A MultiStreamer operates multiple Streamers concurrently (i.e. workers). It reads rows and distributes them to the Streamers.

This allows insertion with a higher insert throughput, where numerous workers are queueing rows and inserting concurrenctly.

Like Streamer, errors are reported from each worker and sent to a unified error channel, where you can decide to read and handle them if necessary.

Contribute

Please check the issues page which might have some TODOs. Feel free to file new bugs and ask for improvements. We welcome pull requests!

Test

# Run unit tests, and check coverage.
$ go test -v -cover

# Run integration tests. This requires an active project, dataset and pem key.
# Make sure you edit the project, dataset, and table name in the .sh file.
$ ./integration_test.sh
$ ./multi_integration_test.sh

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.