haystack

package module
v0.0.0-...-76513a9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2014 License: MIT Imports: 11 Imported by: 0

README

Haystack

A minimal clickstream service written in Go. Utilises AWS Kinesis as the cloud Kafka equivalent.

Package includes the producer service, consumer, and front-end examples to get you started.

Pull requests welcome!

Codeship Status for vly/haystack

AWS Authentication

In order to authenticate with your Kinesis instance, create a new key, download as a csv (rootkey.csv), and place in application root.

Sample Producer

curl -X POST -d '{"cid": "12345", "type": "pageview", "ref": "http://localhost/test.html", "context": ""}' http://localhost:5004/log

Dependencies
Releases
  • 0.0.1 initialisation

Documentation

Index

Constants

View Source
const (
	MAX_MSG_SIZE uint32 = (50 << (10 * 1))
)

Variables

This section is empty.

Functions

func CheckStream

func CheckStream(k *kinesis.Kinesis, streamname string) bool

CheckStream verifies whether a stream already exists

func CreateStream

func CreateStream(k *kinesis.Kinesis, tempStreamName string, shards int) bool

CreateStream creates a new stream

func DeleteStream

func DeleteStream(k *kinesis.Kinesis, streamName string) bool

DeleteStream deletes an existing stream

func GenDict

func GenDict(data []string) map[string]string

generate a dictionary from passed params

func GetMessages

func GetMessages(k *kinesis.Kinesis, streamName string, shardID string) (out [][]byte, ok bool)

func GetShardIterator

func GetShardIterator(k *kinesis.Kinesis, streamName string, shardId string) string

func InitKinesis

func InitKinesis() (*kinesis.Kinesis, bool)

InitKinesis initialises a connection to the Kinesis service

func LogFile

func LogFile(message string)

LogFile passes logging messages to a flatfile

func PassQuery

func PassQuery(stream string, message string) (ok bool)

PassQuery sends the message to a given stream

func PrintRecords

func PrintRecords(records [][]byte)

PrintRecords

func SendMessage

func SendMessage(k *kinesis.Kinesis, streamName string, msg *Message, comms chan bool)

SendMessage generates a new JSON blob and sends to a stream

func ServerInit

func ServerInit(quit chan bool)

ServerInit launches the Producer endpoint ...need to figure out how to do graceful shutdown.

func StoreRecords

func StoreRecords(records []byte) bool

StoreRecords is an example of a local store

Types

type Keys

type Keys struct {
	AccessKey string
	SecretKey string
}

Authentication key struct

func (*Keys) SetEnv

func (k *Keys) SetEnv()

SetEnv stores keys as environment vars

type Message

type Message struct {
	Uid       string `json:"cid"`       // user ID
	Ref       string `json:"ref"`       // referral site
	EventType string `json:"type"`      // type of event
	Data      string `json:"context"`   // data blob
	Timestamp string `json:"timestamp"` // timestamp
}

Message represents the clickstream data to be passed to a stream.

func (*Message) FromJSON

func (m *Message) FromJSON(data []byte) bool

FromJSON (re)contructs a Message struct from a JSON blob

func (*Message) ToJSON

func (m *Message) ToJSON() ([]byte, bool)

ToJSON marshalls the Message struct into a JSON blob

type Producer

type Producer struct {
	Conn *kinesis.Kinesis
}

Base struct for Haystack producer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL