iofilter

package
v1.3.20 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2023 License: Apache-2.0 Imports: 3 Imported by: 1

README

iofilter

Enables adding a filter to any io.ReadCloser.

Given an exiting 'provider' that publishes an io.ReadCloser interface

A caller may call:

  • provider.Read(p []byte) (n int, err error) and
  • provider.Close() error use:

To examin and filter the data transfered use:

  newProvider = iofilter.New(provider, filter)

The newProvider offers an io.ReadCloser interface. The data is sent to filter before it is provided to the newProvider.

If the filter returns an error or panics, the data is discarded and no more data is transfered.

Documentation

Overview

iofilter can help filter data arriving from an io.ReadCloser It allows wraping an existing io.ReadCloser provider and filter the data before exposing it it up the chain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iofilter

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

An Iofilter object maintining internal buffers and state

func New

func New(src io.ReadCloser, filter func(buf []byte, state interface{}), state interface{}, params ...uint) (iof *Iofilter)

Create a New iofilter to wrap an existing provider of an io.ReadCloser interface The new iofilter will expose an io.ReadCloser interface The data will be sent to filter before it is delivered The optional params may include a two integer parameter indicating: 1. The number of buffers which may be at least 3 (default is 3) 2. The size of the buffers (default is 8192) A goroutine will be initiatd to wait on the original provider Read interface and deliver the data to the Readwer using an internal channel

func (*Iofilter) Close

func (iof *Iofilter) Close() error

The io.Close interface of the iofilter

func (*Iofilter) Read

func (iof *Iofilter) Read(dest []byte) (n int, err error)

The io.Read interface of the iofilter

func (*Iofilter) WaitTillDone added in v1.2.0

func (iof *Iofilter) WaitTillDone()

Jump to

Keyboard shortcuts

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