arguments

package
v0.0.0-...-6b2a69b Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2020 License: GPL-3.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Argument

type Argument struct {
	ID         int64    `json:"id"`
	Version    int      `json:"version"`
	Conclusion string   `json:"conclusion"`
	Premises   []string `json:"premises"`
}

Argument is the core data type for the API.

func (*Argument) Validate

func (a *Argument) Validate() error

Validate returns nil if the argument is well-formed, or an error if not.

type ByID

type ByID []Argument

ByID can be used to sort slices of Arguments by ID.

func (ByID) Len

func (c ByID) Len() int

func (ByID) Less

func (c ByID) Less(i, j int) bool

func (ByID) Swap

func (c ByID) Swap(i, j int)

type Deleter

type Deleter interface {
	// Delete deletes an argument (and all its versions) from the site.
	// If the argument didn't exist, the error will be a NotFoundError.
	Delete(ctx context.Context, id int64) error
}

Deleter can delete arguments by ID.

type FetchSomeOptions

type FetchSomeOptions struct {
	// Conclusion only finds arguments which support a given conclusion
	Conclusion string
	// ConclusionContainsAll limits returned arguments to ones with conclusions that
	// contain all the words in this array.
	ConclusionContainsAll []string
	// Count limits the number of fetched arguments.
	Count int
	// Exclude prevents arguments which have any of these IDs from being returned
	Exclude []int64
	// Offset changes which arguments start being returned.
	//
	// An offset of 0 will return arguments starting with the first one.
	// An offset of 1 will skip the first argument, and return arguments starting with the second.
	//
	// When combined with Count, this can be used to paginate the results.
	Offset int
}

FetchSomeOptions has some ways to limit what gets returned when fetching all the arguments.

type GetLive

type GetLive interface {
	// FetchLive should return the latest "active" version of an argument.
	// If no argument with this ID exists, the error should be an arguments.NotFoundError.
	FetchLive(ctx context.Context, id int64) (Argument, error)
}

GetLive can fetch the live version of an argument.

type GetSome

type GetSome interface {
	// FetchSome finds the arguments which match the options.
	// If none exist, error will be nil and the slice empty.
	FetchSome(ctx context.Context, options FetchSomeOptions) ([]Argument, error)
}

GetSome can fetch lists of arguments at once.

type GetVersioned

type GetVersioned interface {
	// FetchVersion should return a particular version of an argument.
	// If the the argument didn't exist, the error should be an arguments.NotFoundError.
	FetchVersion(ctx context.Context, id int64, version int) (Argument, error)
}

GetVersioned returns a specific version of an argument.

type NotFoundError

type NotFoundError struct {
	Message string
	Args    []interface{}
}

NotFoundError will be returned by Store.Fetch() calls when the cause of the returned error is that the argument simply doesn't exist.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type Saver

type Saver interface {
	// Save stores an argument and returns that argument's ID.
	// The ID on the input argument will be ignored.
	Save(ctx context.Context, argument Argument) (id int64, err error)
}

Saver can save arguments.

type Store

type Store interface {
	Deleter
	GetSome
	GetVersioned
	GetLive
	Saver
	Updater
}

Store combines all the functions needed to read & write Arguments into a single interface.

type Updater

type Updater interface {
	// Update makes a new version of the argument. It returns the new argument's version.
	// If no argument with this ID exists, the returned error is an arguments.NotFoundError.
	Update(ctx context.Context, argument Argument) (version int, err error)
}

Updater can update existing arguments.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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