recordio

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: Apache-2.0 Imports: 7 Imported by: 4

Documentation

Overview

Package recordio implements the Mesos variant of RecordIO framing, whereby each record is prefixed by a line that indicates the length of the record in decimal ASCII. The bytes of the record immediately follow the length-line. Zero-length records are allowed.

Example
package main

import (
	"fmt"
	"io"
	"strings"

	"github.com/mesos/mesos-go/api/v1/lib/recordio"
)

func main() {
	var (
		r     = recordio.NewReader(strings.NewReader("6\nhello 0\n6\nworld!"))
		lines []string
	)
	for {
		fr, err := r.ReadFrame()
		if err == io.EOF {
			break
		}
		if err != nil {
			panic(err)
		}
		lines = append(lines, string(fr))
	}
	fmt.Println(lines)
}
Output:

[hello  world!]

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewReader

func NewReader(read io.Reader, opt ...Opt) framing.Reader

NewReader returns a reader that parses frames from a recordio stream.

func ParseUintBytes added in v0.0.4

func ParseUintBytes(s []byte, base int, bitSize int) (n uint64, err error)

ParseUintBytes is like strconv.ParseUint, but using a []byte.

Types

type Opt added in v0.0.4

type Opt func(*reader)

func MaxMessageSize added in v0.0.4

func MaxMessageSize(max int) Opt

MaxMessageSize returns a functional option that configures the internal Scanner's buffer and max token (message) length, in bytes.

type Writer added in v0.0.4

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

func NewWriter added in v0.0.4

func NewWriter(out io.Writer) *Writer

func (*Writer) WriteFrame added in v0.0.4

func (w *Writer) WriteFrame(b []byte) (err error)

Jump to

Keyboard shortcuts

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