No description or website provided.
Go Makefile
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
apps
sqd
Makefile
channel.go
configuration.go
license.txt
readme.md
segment.go
state.go
topic.go

readme.md

Simple Queue

Just playing around with code. Learn more at: http://openmymind.net/Building-A-Queue-Part-1/

package main

import (
    "github.com/karlseguin/sq"
    "strconv"
)

func main() {
    topic, err := sq.OpenTopic("sample", sq.ConfigureTopic().Path("./data/"))
    if err != nil {
        panic(err)
    }
    go func() {
        channel, err := topic.Channel("channel-1", sq.ConfigureChannel())
        if err != nil {
            panic(err)
        }
        channel.Consume(handler)
    }()

    for i := 0; i < 10000; i++ {
        if err := topic.Write([]byte(strconv.Itoa(i))); err != nil {
            panic(err)
        }
    }
}

// returning an error means the message for this channel won't be consumed
func handler(message []byte) error {
    println("handler-a", string(message))
    return nil
}