protocp

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2021 License: Apache-2.0, BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package protocp transforms one record-oriented format into another record-oriented format where the records are protocol buffers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Copier

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

Copier converts an input record-oriented stream to another record-oriented stream.

func NewCopier

func NewCopier(newMessageReader func(io.Reader) (MessageReader, error)) *Copier

NewCopier returns a CSV converter for the given CSV path and reader/writer generators.

newMessageReader returns a function for iterating through csv records as proto.Message instances. newMessageWriter returns a MessageWriter for writing the messages to some output sink.

func (*Copier) Copy

func (cp *Copier) Copy(ctx context.Context, r io.Reader, writer MessageWriter) error

Copy translates each CSV line into a proto.Message and outputs all the protos to a record-oriented writer.

func (*Copier) CopyFile

func (cp *Copier) CopyFile(ctx context.Context, fs FileSystem, fileName string, writer MessageWriter) (finalErr error)

CopyFile opens a file, translates each record of the file into a proto.Message, and outputs all the protos to an output MessageWriter.

type FileSystem

type FileSystem interface {
	OpenRead(context.Context, string) (io.ReadCloser, error)
}

FileSystem provides a file system abstraction in the context of protocp.

type MessageReader

type MessageReader interface {
	// ReadMessage returns the next message in the stream.
	ReadMessage() (proto.Message, error)
}

MessageReader iterates through proto messages.

type MessageWriter

type MessageWriter interface {
	// contains filtered or unexported methods
}

MessageWriter is a generic interface for writing output protos to some record-oriented format.

func NewCompositeRecordWriter

func NewCompositeRecordWriter(writers ...MessageWriter) MessageWriter

NewCompositeRecordWriter returns a MessageWriter that dispatches to several other record writers.

Jump to

Keyboard shortcuts

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