lumbermill: github.com/heroku/lumbermill/Godeps/_workspace/src/github.com/bmizerany/lpx Index | Examples | Files

package lpx

import "github.com/heroku/lumbermill/Godeps/_workspace/src/github.com/bmizerany/lpx"

Code:

package main

import (
    "bufio"
    "github.com/heroku/lumbermill/Godeps/_workspace/src/github.com/bmizerany/lpx"
    "net/http"
)

func main() {
    h := func(w http.ResponseWriter, r *http.Request) {
        lp := lpx.NewReader(bufio.NewReader(r.Body))
        for lp.Next() {
            if string(lp.Header().Name) == "router" {
                decodeMsg(lp.Bytes())
            }
        }
    }
    http.HandleFunc("/drain", h)
    _ = http.ListenAndServe(":8080", nil)
}

func decodeMsg(b []byte) {
    // process b
}

Index

Examples

Package Files

reader.go

type BytesReader Uses

type BytesReader interface {
    io.Reader
    ReadBytes(delim byte) (line []byte, err error)
}
type Header struct {
    PrivalVersion []byte
    Time          []byte
    Hostname      []byte
    Name          []byte
    Procid        []byte
    Msgid         []byte
}

A Header represents a single header in a logplex entry. All fields are popluated.

type Reader Uses

type Reader struct {
    // contains filtered or unexported fields
}

A Reader provides sequential access to logplex packages. The Next method advances to the next entry (including the first), and then can be treated as an io.Reader to access the packages payload.

func NewReader Uses

func NewReader(r BytesReader) *Reader

NewReader creates a new Reader reading from r.

func (*Reader) Bytes Uses

func (r *Reader) Bytes() []byte

Bytes returns the message body.

func (*Reader) Err Uses

func (r *Reader) Err() error

Err returns the first non-EOF error that was encountered by the Reader.

func (*Reader) Header Uses

func (r *Reader) Header() *Header

Header returns the current entries decoded header.

func (*Reader) Next Uses

func (r *Reader) Next() bool

Next advances to the next entry in the stream.

Package lpx imports 3 packages (graph) and is imported by 1 packages. Updated 2016-07-16. Refresh now. Tools for package owners.