olin: within.website/olin/fileresolver Index | Files

package fileresolver

import "within.website/olin/fileresolver"

Package fileresolver is a set of common resolvers for files used in olin.

These packages are dumb. This is intentional. The caller will handle all errors and massage them into the correct format with as little modification as possible on the resolver side.

Index

Package Files

doc.go http.go log.go null.go osfile.go partial.go random.go zero.go

Variables

var (
    ErrNotImplemented = errors.New("fileresolver: not implemeted")
)

Errors exposed by partial.go

func HTTP Uses

func HTTP(cl *http.Client, u *url.URL) (abi.File, error)

HTTP creates a new HTTP transport that pretends to be a file. A process can (and should) have as many of these open as they need active HTTP connections. Users of this package are suggested to use the same underlying HTTP client as much as makes sense.

To use this file:

- write your request body to the file
- flush the file (this blocks for the duration of the HTTP request)
- read the response body from the file
- close the file when you are done reading the response

A new HTTP file will be required for every request on the guest side, but it will be for the best.

func Log Uses

func Log(writer io.Writer, prefix string, flag int) abi.File

Log returns a file that redirects all write calls to a standard library logger with the given prefix and flags.

For more information, please see the spec here: https://github.com/CommonWA/cwa-spec/blob/master/schemes/log.md

func NewOSFile Uses

func NewOSFile(fd uintptr, name string) abi.File

NewOSFile creates a file backed by an OS file descriptor without buffering. This is kinda dangerous. Only do this if you know what you are doing.

func Null Uses

func Null() abi.File

Null is a file that emulates /dev/null on Linux.

For more information, please see the spec here: https://github.com/CommonWA/cwa-spec/blob/master/schemes/null.md

func Random Uses

func Random() abi.File

Random returns a file that reads cryptographically random data.

func Reader Uses

func Reader(r io.Reader, name string) abi.File

Reader wraps an io.Reader as an abi.File.

func Writer Uses

func Writer(w io.Writer, name string) abi.File

Writer wraps an io.Writer as an abi.File.

func Zero Uses

func Zero() abi.File

Zero is a file that does nothing.

For more information, please see the spec here: https://github.com/CommonWA/cwa-spec/blob/master/schemes/zero.md

type OSFile Uses

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

OSFile implements File backed by a raw operating system file.

This doesn't buffer I/O.

func (OSFile) Close Uses

func (o OSFile) Close() error

Close closes this OS file.

func (OSFile) Flush Uses

func (OSFile) Flush() error

Flush does nothing.

func (OSFile) Name Uses

func (o OSFile) Name() string

Name returns the file's name.

func (OSFile) Read Uses

func (o OSFile) Read(p []byte) (int, error)

Read reads data from the OS file.

func (OSFile) Write Uses

func (o OSFile) Write(p []byte) (int, error)

Write writes data to the OS file.

Package fileresolver imports 11 packages (graph) and is imported by 6 packages. Updated 2019-11-19. Refresh now. Tools for package owners.