paasio

package
v0.0.0-...-427ddc2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2017 License: MIT Imports: 2 Imported by: 0

README

Paasio

Report network IO statistics.

You are writing a PaaS, and you need a way to bill customers based on network and filesystem usage.

Create a wrapper for network connections and files that can report IO statistics. The wrapper must report:

  • The total number of bytes read/written.
  • The total number of read/write operations.

Running the tests

To run the tests run the command go test from within the exercise directory.

If the test suite contains benchmarks, you can run these with the -bench flag:

go test -bench .

Keep in mind that each reviewer will run benchmarks on a different machine, with different specs, so the results from these benchmark tests may vary.

Further information

For more detailed information about the Go track, including how to get help if you're having trouble, please visit the exercism.io Go language page.

Source

Brian Matsuo https://github.com/bmatsuo

Submitting Incomplete Solutions

It's possible to submit an incomplete solution so you can see how others have completed the exercise.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReadCounter

type ReadCounter interface {
	io.Reader
	// ReadCount returns the total number of bytes successfully read along
	// with the total number of calls to Read().
	ReadCount() (n int64, nops int)
}

ReadCounter is an interface describing objects that can be read from, and that can count the number of times they have been read from.

If multiple goroutines concurrently call Read, implementations are not required to provide any guarantees about interleaving of the Read calls. However, implementations MUST guarantee that calls to ReadCount always return correct results even in the presence of concurrent Read calls.

func NewReadCounter

func NewReadCounter(r io.Reader) ReadCounter

NewReadCounter returns an implementation of ReadCounter. Calls to r.Read() are not guaranteed to be synchronized.

type ReadWriteCounter

type ReadWriteCounter interface {
	ReadCounter
	WriteCounter
}

ReadWriteCounter is the union of ReadCounter and WriteCounter.

All guarantees that apply to either of ReadCounter or WriteCounter also apply to ReadWriteCounter.

func NewReadWriteCounter

func NewReadWriteCounter(rw io.ReadWriter) ReadWriteCounter

NewReadWriteCounter returns an implementation of ReadWriteCounter. Calls to rw.Write() and rw.Read() are not guaranteed to be synchronized.

type WriteCounter

type WriteCounter interface {
	io.Writer
	// WriteCount returns the total number of bytes successfully written along
	// with the total number of calls to Write().
	WriteCount() (n int64, nops int)
}

WriteCounter is an interface describing objects that can be written to, and that can count the number of times they have been written to.

If multiple goroutines concurrently call Write, implementations are not required to provide any guarantees about interleaving of the Write calls. However, implementations MUST guarantee that calls to WriteCount always return correct results even in the presence of concurrent Write calls.

func NewWriteCounter

func NewWriteCounter(w io.Writer) WriteCounter

NewWriteCounter returns an implementation of WriteCounter. Calls to w.Write() are not guaranteed to be synchronized.

Jump to

Keyboard shortcuts

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