Skip to content

A client for http streaming API's in Go: Twitter, Flowdock, DataSift, Custom

Notifications You must be signed in to change notification settings

araddon/httpstream

This branch is 60 commits ahead of hoisie/twitterstream:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

96fc3b5 · Feb 21, 2017
Feb 24, 2013
Dec 22, 2013
Jul 26, 2012
Aug 10, 2012
Mar 10, 2012
Oct 24, 2012
Aug 14, 2012
Feb 21, 2017
Jul 18, 2014
Dec 3, 2012

Repository files navigation

httpstream was forked from https://github.com/hoisie/twitterstream

A Go http streaming client. http-streaming is most-associated with the twitter stream api. This client works with twitter, but has also been tested against the data-sift stream as well as http://flowdock.com

This is an example of using the Twitter stream sample :

package main

import "github.com/araddon/httpstream"

func main() {
    stream := make(chan []byte)
    done := make(chan bool)
    client := httpstream.NewBasicAuthClient("yourusername", "pwd", func(line []byte) {
        stream <- line
    })
    go func() {
        _ := client.Sample(done)
        for line := range stream {
            println(string(line))
            // heavy lifting like json serialization, etc
        }
    }()
    _ = <- done
}

There are a few more samples in the Examples folder.

Use a channel instead of func :

    stream := make(chan []byte)
    done := make(chan bool)
    client := httpstream.NewChannelClient("yourusername", "pwd", stream)
    go func() {
        for line := range stream {
            println(string(line))
        }
    }()
    client.Sample(done)
    _ = <- done

For more information about streaming apis

About

A client for http streaming API's in Go: Twitter, Flowdock, DataSift, Custom

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%