fileresolver

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

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

Constants

This section is empty.

Variables

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

Errors exposed by partial.go

Functions

func HTTP

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

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

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

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

func Random() abi.File

Random returns a file that reads cryptographically random data.

func Reader

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

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

func Writer

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

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

func Zero

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

Types

type OSFile

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

func (o OSFile) Close() error

Close closes this OS file.

func (OSFile) Flush

func (OSFile) Flush() error

Flush does nothing.

func (OSFile) Name

func (o OSFile) Name() string

Name returns the file's name.

func (OSFile) Read

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

Read reads data from the OS file.

func (OSFile) Write

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

Write writes data to the OS file.

Jump to

Keyboard shortcuts

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