basic

package
v0.0.0-...-c04549c Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package basic implements the basic EigenTrust algorithm.

Package basic provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen version v1.12.4 DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Canonicalize

func Canonicalize(entries []sparse.Entry) error

Canonicalize scales sparse entries in-place so that their values sum to one.

If entries sum to zero, Canonicalize returns ErrZeroSum.

func CanonicalizeLocalTrust

func CanonicalizeLocalTrust(
	localTrust *sparse.Matrix, preTrust *sparse.Vector,
) error

CanonicalizeLocalTrust canonicalizes localTrust in-place, i.e. scales each row so that its entries sum to one.

Zero rows are replaced by preTrust vector.

The receiver and trustVector must have the same dimension.

func CanonicalizeTrustVector

func CanonicalizeTrustVector(v *sparse.Vector)

CanonicalizeTrustVector canonicalizes trustVector in-place, i.e. scales it so that the elements sum to one, or makes it a uniform vector that sums to one if the receiver is a zero vector.

func Compute

func Compute(
	ctx context.Context, c *sparse.Matrix, p *sparse.Vector,
	a float64, e float64,
	opts ...ComputeOpt,
) (*sparse.Vector, error)

Compute computes EigenTrust scores.

Local trust (c) and pre-trust (p) must have already been canonicalized.

Alpha (a) and epsilon (e) are the pre-trust bias and iteration threshold, as defined in the EigenTrust paper.

Compute accepts options (opts) which modifies its behavior. See their documentation for details.

Compute terminates EigenTrust iterations when the trust vector converges, i.e. the Frobenius norm of trust vector delta falls below epsilon threshold. Also see WithFlatTail for an additional/alternative termination criterion based upon ranking stability.

func GetSwagger

func GetSwagger() (swagger *openapi3.T, err error)

GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.

func NewComputeRequest

func NewComputeRequest(server string, body ComputeJSONRequestBody) (*http.Request, error)

NewComputeRequest calls the generic Compute builder with application/json body

func NewComputeRequestWithBody

func NewComputeRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewComputeRequestWithBody generates requests for Compute with any type of body

func NewComputeWithStatsRequest

func NewComputeWithStatsRequest(server string, body ComputeWithStatsJSONRequestBody) (*http.Request, error)

NewComputeWithStatsRequest calls the generic ComputeWithStats builder with application/json body

func NewComputeWithStatsRequestWithBody

func NewComputeWithStatsRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewComputeWithStatsRequestWithBody generates requests for ComputeWithStats with any type of body

func NewDeleteLocalTrustRequest

func NewDeleteLocalTrustRequest(server string, id LocalTrustIdParam) (*http.Request, error)

NewDeleteLocalTrustRequest generates requests for DeleteLocalTrust

func NewGetLocalTrustRequest

func NewGetLocalTrustRequest(server string, id LocalTrustIdParam) (*http.Request, error)

NewGetLocalTrustRequest generates requests for GetLocalTrust

func NewHeadLocalTrustRequest

func NewHeadLocalTrustRequest(server string, id LocalTrustIdParam) (*http.Request, error)

NewHeadLocalTrustRequest generates requests for HeadLocalTrust

func NewRouter

func NewRouter() http.Handler

func NewUpdateLocalTrustRequest

func NewUpdateLocalTrustRequest(server string, id LocalTrustIdParam, params *UpdateLocalTrustParams, body UpdateLocalTrustJSONRequestBody) (*http.Request, error)

NewUpdateLocalTrustRequest calls the generic UpdateLocalTrust builder with application/json body

func NewUpdateLocalTrustRequestWithBody

func NewUpdateLocalTrustRequestWithBody(server string, id LocalTrustIdParam, params *UpdateLocalTrustParams, contentType string, body io.Reader) (*http.Request, error)

NewUpdateLocalTrustRequestWithBody generates requests for UpdateLocalTrust with any type of body

func ParsePeerId

func ParsePeerId(s string, peerIndices map[string]int) (index int, err error)

ParsePeerId parses s and returns the peer index.

If peerIndices is not nil, s is considered to be a peer name found therein; otherwise, s is considered to be a peer index integer literal.

func ParseTrustLevel

func ParseTrustLevel(s string) (level float64, err error)

ParseTrustLevel parses s as a non-negative trust level and returns it.

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

func ReadLocalTrustFromCsv

func ReadLocalTrustFromCsv(
	reader CsvReader, peerIndices map[string]int,
) (*sparse.Matrix, error)

ReadLocalTrustFromCsv reads a local trust matrix from the given CSV file.

func ReadPeerNamesFromCsv

func ReadPeerNamesFromCsv(reader CsvReader) (
	names []string, indices map[string]int, err error,
)

func ReadTrustVectorFromCsv

func ReadTrustVectorFromCsv(
	reader CsvReader, peerIndices map[string]int,
) (*sparse.Vector, error)

ReadTrustVectorFromCsv reads a trust vector from the given CSV file.

func RegisterHandlers

func RegisterHandlers(router EchoRouter, si ServerInterface)

RegisterHandlers adds each server route to the EchoRouter.

func RegisterHandlersWithBaseURL

func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string)

Registers handlers, and prepends BaseURL to the paths, so that the paths can be served under a prefix.

Types

type Client

type Client struct {
	// The endpoint of the server conforming to this interface, with scheme,
	// https://api.deepmap.com for example. This can contain a path relative
	// to the server, such as https://api.deepmap.com/dev-test, and all the
	// paths in the swagger spec will be appended to the server.
	Server string

	// Doer for performing requests, typically a *http.Client with any
	// customized settings, such as certificate chains.
	Client HttpRequestDoer

	// A list of callbacks for modifying requests which are generated before sending over
	// the network.
	RequestEditors []RequestEditorFn
}

Client which conforms to the OpenAPI3 specification for this service.

func NewClient

func NewClient(server string, opts ...ClientOption) (*Client, error)

Creates a new Client, with reasonable defaults

func (*Client) Compute

func (c *Client) Compute(ctx context.Context, body ComputeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) ComputeWithBody

func (c *Client) ComputeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) ComputeWithStats

func (c *Client) ComputeWithStats(ctx context.Context, body ComputeWithStatsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) ComputeWithStatsWithBody

func (c *Client) ComputeWithStatsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) DeleteLocalTrust

func (c *Client) DeleteLocalTrust(ctx context.Context, id LocalTrustIdParam, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetLocalTrust

func (c *Client) GetLocalTrust(ctx context.Context, id LocalTrustIdParam, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) HeadLocalTrust

func (c *Client) HeadLocalTrust(ctx context.Context, id LocalTrustIdParam, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) UpdateLocalTrust

func (*Client) UpdateLocalTrustWithBody

func (c *Client) UpdateLocalTrustWithBody(ctx context.Context, id LocalTrustIdParam, params *UpdateLocalTrustParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

type ClientInterface

type ClientInterface interface {
	// Compute request with any body
	ComputeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	Compute(ctx context.Context, body ComputeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// ComputeWithStats request with any body
	ComputeWithStatsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	ComputeWithStats(ctx context.Context, body ComputeWithStatsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// DeleteLocalTrust request
	DeleteLocalTrust(ctx context.Context, id LocalTrustIdParam, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GetLocalTrust request
	GetLocalTrust(ctx context.Context, id LocalTrustIdParam, reqEditors ...RequestEditorFn) (*http.Response, error)

	// HeadLocalTrust request
	HeadLocalTrust(ctx context.Context, id LocalTrustIdParam, reqEditors ...RequestEditorFn) (*http.Response, error)

	// UpdateLocalTrust request with any body
	UpdateLocalTrustWithBody(ctx context.Context, id LocalTrustIdParam, params *UpdateLocalTrustParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	UpdateLocalTrust(ctx context.Context, id LocalTrustIdParam, params *UpdateLocalTrustParams, body UpdateLocalTrustJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
}

The interface specification for the client above.

type ClientOption

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the baseURL.

func WithHTTPClient

func WithHTTPClient(doer HttpRequestDoer) ClientOption

WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.

func WithRequestEditorFn

func WithRequestEditorFn(fn RequestEditorFn) ClientOption

WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.

type ClientWithResponses

type ClientWithResponses struct {
	ClientInterface
}

ClientWithResponses builds on ClientInterface to offer response payloads

func NewClientWithResponses

func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error)

NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling

func (*ClientWithResponses) ComputeWithBodyWithResponse

func (c *ClientWithResponses) ComputeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ComputeResponse, error)

ComputeWithBodyWithResponse request with arbitrary body returning *ComputeResponse

func (*ClientWithResponses) ComputeWithResponse

func (c *ClientWithResponses) ComputeWithResponse(ctx context.Context, body ComputeJSONRequestBody, reqEditors ...RequestEditorFn) (*ComputeResponse, error)

func (*ClientWithResponses) ComputeWithStatsWithBodyWithResponse

func (c *ClientWithResponses) ComputeWithStatsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ComputeWithStatsResponse, error)

ComputeWithStatsWithBodyWithResponse request with arbitrary body returning *ComputeWithStatsResponse

func (*ClientWithResponses) ComputeWithStatsWithResponse

func (c *ClientWithResponses) ComputeWithStatsWithResponse(ctx context.Context, body ComputeWithStatsJSONRequestBody, reqEditors ...RequestEditorFn) (*ComputeWithStatsResponse, error)

func (*ClientWithResponses) DeleteLocalTrustWithResponse

func (c *ClientWithResponses) DeleteLocalTrustWithResponse(ctx context.Context, id LocalTrustIdParam, reqEditors ...RequestEditorFn) (*DeleteLocalTrustResponse, error)

DeleteLocalTrustWithResponse request returning *DeleteLocalTrustResponse

func (*ClientWithResponses) GetLocalTrustWithResponse

func (c *ClientWithResponses) GetLocalTrustWithResponse(ctx context.Context, id LocalTrustIdParam, reqEditors ...RequestEditorFn) (*GetLocalTrustResponse, error)

GetLocalTrustWithResponse request returning *GetLocalTrustResponse

func (*ClientWithResponses) HeadLocalTrustWithResponse

func (c *ClientWithResponses) HeadLocalTrustWithResponse(ctx context.Context, id LocalTrustIdParam, reqEditors ...RequestEditorFn) (*HeadLocalTrustResponse, error)

HeadLocalTrustWithResponse request returning *HeadLocalTrustResponse

func (*ClientWithResponses) UpdateLocalTrustWithBodyWithResponse

func (c *ClientWithResponses) UpdateLocalTrustWithBodyWithResponse(ctx context.Context, id LocalTrustIdParam, params *UpdateLocalTrustParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateLocalTrustResponse, error)

UpdateLocalTrustWithBodyWithResponse request with arbitrary body returning *UpdateLocalTrustResponse

func (*ClientWithResponses) UpdateLocalTrustWithResponse

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// Compute request with any body
	ComputeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ComputeResponse, error)

	ComputeWithResponse(ctx context.Context, body ComputeJSONRequestBody, reqEditors ...RequestEditorFn) (*ComputeResponse, error)

	// ComputeWithStats request with any body
	ComputeWithStatsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ComputeWithStatsResponse, error)

	ComputeWithStatsWithResponse(ctx context.Context, body ComputeWithStatsJSONRequestBody, reqEditors ...RequestEditorFn) (*ComputeWithStatsResponse, error)

	// DeleteLocalTrust request
	DeleteLocalTrustWithResponse(ctx context.Context, id LocalTrustIdParam, reqEditors ...RequestEditorFn) (*DeleteLocalTrustResponse, error)

	// GetLocalTrust request
	GetLocalTrustWithResponse(ctx context.Context, id LocalTrustIdParam, reqEditors ...RequestEditorFn) (*GetLocalTrustResponse, error)

	// HeadLocalTrust request
	HeadLocalTrustWithResponse(ctx context.Context, id LocalTrustIdParam, reqEditors ...RequestEditorFn) (*HeadLocalTrustResponse, error)

	// UpdateLocalTrust request with any body
	UpdateLocalTrustWithBodyWithResponse(ctx context.Context, id LocalTrustIdParam, params *UpdateLocalTrustParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateLocalTrustResponse, error)

	UpdateLocalTrustWithResponse(ctx context.Context, id LocalTrustIdParam, params *UpdateLocalTrustParams, body UpdateLocalTrustJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateLocalTrustResponse, error)
}

ClientWithResponsesInterface is the interface specification for the client with responses above.

type Compute200JSONResponse

type Compute200JSONResponse TrustVectorRef

func (Compute200JSONResponse) VisitComputeResponse

func (response Compute200JSONResponse) VisitComputeResponse(w http.ResponseWriter) error

type Compute400JSONResponse

type Compute400JSONResponse struct{ InvalidRequestJSONResponse }

func (Compute400JSONResponse) VisitComputeResponse

func (response Compute400JSONResponse) VisitComputeResponse(w http.ResponseWriter) error

type ComputeJSONBody

type ComputeJSONBody struct {
	Alpha   *float64 `json:"alpha,omitempty"`
	Epsilon *float64 `json:"epsilon,omitempty"`

	// FlatTail The length of the flat tail
	// (ranking unchanged from previous iteration)
	// that must be seen before terminating the recursion.
	// 0 means a flat tail need not be seen,
	// and the recursion is terminated solely based upon epsilon.
	FlatTail *int `json:"flatTail,omitempty"`

	// InitialTrust Refers to a trust vector.
	InitialTrust *TrustVectorRef `json:"initialTrust,omitempty"`

	// LocalTrust refers to a local trust.
	LocalTrust LocalTrustRef `json:"localTrust"`

	// MaxIterations The maximum number of iterations after which to stop
	// even if other termination criteria are not met.
	// 0 means no limit.
	MaxIterations *int `json:"maxIterations,omitempty"`

	// NumLeaders The number of top-ranking peers to consider
	// for the purpose of flat-tail algorithm.  0 means everyone.
	NumLeaders *int `json:"numLeaders,omitempty"`

	// PreTrust Refers to a trust vector.
	PreTrust *TrustVectorRef `json:"preTrust,omitempty"`
}

ComputeJSONBody defines parameters for Compute.

type ComputeJSONRequestBody

type ComputeJSONRequestBody ComputeJSONBody

ComputeJSONRequestBody defines body for Compute for application/json ContentType.

type ComputeOpt

type ComputeOpt func(*ComputeOpts)

ComputeOpt is one Compute option.

func WithFlatTail

func WithFlatTail(l int) ComputeOpt

WithFlatTail (formerly the "flatTail" parameter) enables the flat-tail ranking stability check: It tells Compute to iterate until the trust ranking stabilizes, i.e. the same ranking is observed for l+1 iterations.

This is in addition to the usual epsilon-based termination criterion: Iteration terminates only when both criteria are met. In order to use ranking stability only, pass Compute with e=1 to disable the epsilon-based convergence check.

func WithFlatTailNumLeaders

func WithFlatTailNumLeaders(n int) ComputeOpt

WithFlatTailNumLeaders (formerly the "numLeaders" parameter) tells Compute to limit trust ranking stability check to the top n peers.

func WithFlatTailStats

func WithFlatTailStats(stats *FlatTailStats) ComputeOpt

WithFlatTailStats (formerly the "flatTailStats" parameter) tells Compute to populate the given struct with flat-tail algorithm stats upon completion.

func WithInitialTrust

func WithInitialTrust(t0 *sparse.Vector) ComputeOpt

WithInitialTrust (formerly the "t0" parameter) tells Compute to start iteration at the given trust vector instead of the pre-trust vector.

func WithMaxIterations

func WithMaxIterations(n int) ComputeOpt

WithMaxIterations tells Compute to iterate at most n times, even if the other termination criteria are not met. 0 means unlimited.

func WithResultIn

func WithResultIn(t *sparse.Vector) ComputeOpt

WithResultIn (formerly the "t" parameter). tells Compute to store the computation result in the given sparse vector without allocating one.

type ComputeOpts

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

ComputeOpts contains options for the Compute function.

type ComputeRequestBody

type ComputeRequestBody struct {
	Alpha   *float64 `json:"alpha,omitempty"`
	Epsilon *float64 `json:"epsilon,omitempty"`

	// FlatTail The length of the flat tail
	// (ranking unchanged from previous iteration)
	// that must be seen before terminating the recursion.
	// 0 means a flat tail need not be seen,
	// and the recursion is terminated solely based upon epsilon.
	FlatTail *int `json:"flatTail,omitempty"`

	// InitialTrust Refers to a trust vector.
	InitialTrust *TrustVectorRef `json:"initialTrust,omitempty"`

	// LocalTrust refers to a local trust.
	LocalTrust LocalTrustRef `json:"localTrust"`

	// MaxIterations The maximum number of iterations after which to stop
	// even if other termination criteria are not met.
	// 0 means no limit.
	MaxIterations *int `json:"maxIterations,omitempty"`

	// NumLeaders The number of top-ranking peers to consider
	// for the purpose of flat-tail algorithm.  0 means everyone.
	NumLeaders *int `json:"numLeaders,omitempty"`

	// PreTrust Refers to a trust vector.
	PreTrust *TrustVectorRef `json:"preTrust,omitempty"`
}

ComputeRequestBody defines model for ComputeRequestBody.

type ComputeRequestObject

type ComputeRequestObject struct {
	Body *ComputeJSONRequestBody
}

type ComputeResponse

type ComputeResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *TrustVectorRef
	JSON400      *struct {
		// Message Describes the error in a human-readable message.
		//
		// It may be empty.
		Message string `json:"message"`
	}
}

func ParseComputeResponse

func ParseComputeResponse(rsp *http.Response) (*ComputeResponse, error)

ParseComputeResponse parses an HTTP response from a ComputeWithResponse call

func (ComputeResponse) Status

func (r ComputeResponse) Status() string

Status returns HTTPResponse.Status

func (ComputeResponse) StatusCode

func (r ComputeResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type ComputeResponseObject

type ComputeResponseObject interface {
	VisitComputeResponse(w http.ResponseWriter) error
}

type ComputeWithStats200JSONResponse

type ComputeWithStats200JSONResponse struct {
	ComputeWithStatsResponseOKJSONResponse
}

func (ComputeWithStats200JSONResponse) VisitComputeWithStatsResponse

func (response ComputeWithStats200JSONResponse) VisitComputeWithStatsResponse(w http.ResponseWriter) error

type ComputeWithStats400JSONResponse

type ComputeWithStats400JSONResponse struct{ InvalidRequestJSONResponse }

func (ComputeWithStats400JSONResponse) VisitComputeWithStatsResponse

func (response ComputeWithStats400JSONResponse) VisitComputeWithStatsResponse(w http.ResponseWriter) error

type ComputeWithStatsJSONBody

type ComputeWithStatsJSONBody struct {
	Alpha   *float64 `json:"alpha,omitempty"`
	Epsilon *float64 `json:"epsilon,omitempty"`

	// FlatTail The length of the flat tail
	// (ranking unchanged from previous iteration)
	// that must be seen before terminating the recursion.
	// 0 means a flat tail need not be seen,
	// and the recursion is terminated solely based upon epsilon.
	FlatTail *int `json:"flatTail,omitempty"`

	// InitialTrust Refers to a trust vector.
	InitialTrust *TrustVectorRef `json:"initialTrust,omitempty"`

	// LocalTrust refers to a local trust.
	LocalTrust LocalTrustRef `json:"localTrust"`

	// MaxIterations The maximum number of iterations after which to stop
	// even if other termination criteria are not met.
	// 0 means no limit.
	MaxIterations *int `json:"maxIterations,omitempty"`

	// NumLeaders The number of top-ranking peers to consider
	// for the purpose of flat-tail algorithm.  0 means everyone.
	NumLeaders *int `json:"numLeaders,omitempty"`

	// PreTrust Refers to a trust vector.
	PreTrust *TrustVectorRef `json:"preTrust,omitempty"`
}

ComputeWithStatsJSONBody defines parameters for ComputeWithStats.

type ComputeWithStatsJSONRequestBody

type ComputeWithStatsJSONRequestBody ComputeWithStatsJSONBody

ComputeWithStatsJSONRequestBody defines body for ComputeWithStats for application/json ContentType.

type ComputeWithStatsRequestObject

type ComputeWithStatsRequestObject struct {
	Body *ComputeWithStatsJSONRequestBody
}

type ComputeWithStatsResponse

type ComputeWithStatsResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *struct {
		// EigenTrust Refers to a trust vector.
		EigenTrust TrustVectorRef `json:"eigenTrust"`

		// FlatTailStats Flat-tail algorithm stats and peer ranking.
		FlatTailStats FlatTailStats `json:"flatTailStats"`
	}
	JSON400 *struct {
		// Message Describes the error in a human-readable message.
		//
		// It may be empty.
		Message string `json:"message"`
	}
}

func ParseComputeWithStatsResponse

func ParseComputeWithStatsResponse(rsp *http.Response) (*ComputeWithStatsResponse, error)

ParseComputeWithStatsResponse parses an HTTP response from a ComputeWithStatsWithResponse call

func (ComputeWithStatsResponse) Status

func (r ComputeWithStatsResponse) Status() string

Status returns HTTPResponse.Status

func (ComputeWithStatsResponse) StatusCode

func (r ComputeWithStatsResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type ComputeWithStatsResponseOK

type ComputeWithStatsResponseOK struct {
	// EigenTrust Refers to a trust vector.
	EigenTrust TrustVectorRef `json:"eigenTrust"`

	// FlatTailStats Flat-tail algorithm stats and peer ranking.
	FlatTailStats FlatTailStats `json:"flatTailStats"`
}

ComputeWithStatsResponseOK defines model for ComputeWithStatsResponseOK.

type ComputeWithStatsResponseOKJSONResponse

type ComputeWithStatsResponseOKJSONResponse struct {
	// EigenTrust Refers to a trust vector.
	EigenTrust TrustVectorRef `json:"eigenTrust"`

	// FlatTailStats Flat-tail algorithm stats and peer ranking.
	FlatTailStats FlatTailStats `json:"flatTailStats"`
}

type ComputeWithStatsResponseObject

type ComputeWithStatsResponseObject interface {
	VisitComputeWithStatsResponse(w http.ResponseWriter) error
}

type CsvReader

type CsvReader interface {
	Read() (fields []string, err error)
}

CsvReader reads from a CSV file.

type DeleteLocalTrust204Response

type DeleteLocalTrust204Response struct {
}

func (DeleteLocalTrust204Response) VisitDeleteLocalTrustResponse

func (response DeleteLocalTrust204Response) VisitDeleteLocalTrustResponse(w http.ResponseWriter) error

type DeleteLocalTrust400JSONResponse

type DeleteLocalTrust400JSONResponse struct{ InvalidRequestJSONResponse }

func (DeleteLocalTrust400JSONResponse) VisitDeleteLocalTrustResponse

func (response DeleteLocalTrust400JSONResponse) VisitDeleteLocalTrustResponse(w http.ResponseWriter) error

type DeleteLocalTrust404Response

type DeleteLocalTrust404Response struct {
}

func (DeleteLocalTrust404Response) VisitDeleteLocalTrustResponse

func (response DeleteLocalTrust404Response) VisitDeleteLocalTrustResponse(w http.ResponseWriter) error

type DeleteLocalTrustRequestObject

type DeleteLocalTrustRequestObject struct {
	Id LocalTrustIdParam `json:"id,omitempty"`
}

type DeleteLocalTrustResponse

type DeleteLocalTrustResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON400      *struct {
		// Message Describes the error in a human-readable message.
		//
		// It may be empty.
		Message string `json:"message"`
	}
}

func ParseDeleteLocalTrustResponse

func ParseDeleteLocalTrustResponse(rsp *http.Response) (*DeleteLocalTrustResponse, error)

ParseDeleteLocalTrustResponse parses an HTTP response from a DeleteLocalTrustWithResponse call

func (DeleteLocalTrustResponse) Status

func (r DeleteLocalTrustResponse) Status() string

Status returns HTTPResponse.Status

func (DeleteLocalTrustResponse) StatusCode

func (r DeleteLocalTrustResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type DeleteLocalTrustResponseObject

type DeleteLocalTrustResponseObject interface {
	VisitDeleteLocalTrustResponse(w http.ResponseWriter) error
}

type EchoRouter

type EchoRouter interface {
	CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}

This is a simple interface which specifies echo.Route addition functions which are present on both echo.Echo and echo.Group, since we want to allow using either of them for path registration

type FlatTailStats

type FlatTailStats struct {
	// DeltaNorm The d value as of the head of the last flat-tail.
	// This can be used to fine-tune epsilon
	// even when not using flat-tail algorithm.
	DeltaNorm float64 `json:"deltaNorm"`

	// Length The flat-tail length (say, L, then
	// the last L+1 iterations had the same ranking).
	// This is the number of iterations that could be saved
	// by using flat-tail algorithm
	// (passing flatTail equal to the threshold stat below)
	// while achieving the same result.
	Length int `json:"length"`

	// Ranking The sorted ranking of peer indices.
	// Peers not found here have zero global trust.
	Ranking []int `json:"ranking"`

	// Threshold The suggested minimum threshold parameter (flatTail).
	// It is determined from false flat tails observed.
	// Example: If a ranking pattern ABCDDEEEEFFFFFFFFFF was observed
	// (each letter is a distinct ranking) before epsilon was reached,
	// both DD and EEEE are false flat tails
	// of length 1 and 3 respectively.
	// In this case, Threshold=4 is suggested in order to ignore
	// these false flat tails.
	Threshold int `json:"threshold"`
}

FlatTailStats Flat-tail algorithm stats and peer ranking.

type GetLocalTrust200JSONResponse

type GetLocalTrust200JSONResponse InlineLocalTrust

func (GetLocalTrust200JSONResponse) VisitGetLocalTrustResponse

func (response GetLocalTrust200JSONResponse) VisitGetLocalTrustResponse(w http.ResponseWriter) error

type GetLocalTrust404Response

type GetLocalTrust404Response struct {
}

func (GetLocalTrust404Response) VisitGetLocalTrustResponse

func (response GetLocalTrust404Response) VisitGetLocalTrustResponse(w http.ResponseWriter) error

type GetLocalTrustRequestObject

type GetLocalTrustRequestObject struct {
	Id LocalTrustIdParam `json:"id,omitempty"`
}

type GetLocalTrustResponse

type GetLocalTrustResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *InlineLocalTrust
}

func ParseGetLocalTrustResponse

func ParseGetLocalTrustResponse(rsp *http.Response) (*GetLocalTrustResponse, error)

ParseGetLocalTrustResponse parses an HTTP response from a GetLocalTrustWithResponse call

func (GetLocalTrustResponse) Status

func (r GetLocalTrustResponse) Status() string

Status returns HTTPResponse.Status

func (GetLocalTrustResponse) StatusCode

func (r GetLocalTrustResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type GetLocalTrustResponseObject

type GetLocalTrustResponseObject interface {
	VisitGetLocalTrustResponse(w http.ResponseWriter) error
}

type HTTPError

type HTTPError struct {
	Code  int
	Inner error
}

func (HTTPError) Error

func (e HTTPError) Error() string

type HeadLocalTrust204Response

type HeadLocalTrust204Response struct {
}

func (HeadLocalTrust204Response) VisitHeadLocalTrustResponse

func (response HeadLocalTrust204Response) VisitHeadLocalTrustResponse(w http.ResponseWriter) error

type HeadLocalTrust404Response

type HeadLocalTrust404Response struct {
}

func (HeadLocalTrust404Response) VisitHeadLocalTrustResponse

func (response HeadLocalTrust404Response) VisitHeadLocalTrustResponse(w http.ResponseWriter) error

type HeadLocalTrustRequestObject

type HeadLocalTrustRequestObject struct {
	Id LocalTrustIdParam `json:"id,omitempty"`
}

type HeadLocalTrustResponse

type HeadLocalTrustResponse struct {
	Body         []byte
	HTTPResponse *http.Response
}

func ParseHeadLocalTrustResponse

func ParseHeadLocalTrustResponse(rsp *http.Response) (*HeadLocalTrustResponse, error)

ParseHeadLocalTrustResponse parses an HTTP response from a HeadLocalTrustWithResponse call

func (HeadLocalTrustResponse) Status

func (r HeadLocalTrustResponse) Status() string

Status returns HTTPResponse.Status

func (HeadLocalTrustResponse) StatusCode

func (r HeadLocalTrustResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type HeadLocalTrustResponseObject

type HeadLocalTrustResponseObject interface {
	VisitHeadLocalTrustResponse(w http.ResponseWriter) error
}

type HttpRequestDoer

type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer performs HTTP requests.

The standard http.Client implements this interface.

type InlineLocalTrust

type InlineLocalTrust struct {
	// Entries Contains the non-zero entries in the local trust matrix.
	//
	// Truster/trustee pairs missing here are assigned zero direct trust,
	// i.e. no trust relationship.
	Entries []InlineLocalTrustEntry `json:"entries"`

	// Size Denotes the number of peers in the local trust,
	// i.e. its square dimension.
	Size int `json:"size"`
}

InlineLocalTrust Refers to a local trust matrix "inline".

Instead of pointing (referencing) to an externally stored local trust, it carries the contents of the local trust matrix within the reference object itself.

type InlineLocalTrustEntry

type InlineLocalTrustEntry struct {
	// I Denotes the trusting peer.
	//
	// It is a zero-based index,
	// and must be less than the size (dimension)
	// of the enclosing local trust matrix.
	I int `json:"i"`

	// J Denotes the trusted peer.
	//
	// It is a zero-based index,
	// and must be less than the size (dimension)
	// of the enclosing local trust matrix.
	J int `json:"j"`

	// V Represents the (positive) amount of trust
	// placed by peer `i` in peer `j`.
	V float64 `json:"v"`
}

InlineLocalTrustEntry Represents an entry in the local trust matrix.

Denotes that one peer (`i`) places a direct trust in another peer (`j`) by a specific amount (`v`).

type InlineTrustVector

type InlineTrustVector struct {
	// Entries Contains the non-zero entries in the trust vector.
	//
	// Peers missing here are assigned zero amount of trust.
	Entries []InlineTrustVectorEntry `json:"entries"`

	// Scheme A fixed string `"inline"` to denote an inline reference.
	Scheme InlineTrustVectorScheme `json:"scheme"`

	// Size Denotes the number of peers in the trust vector, i.e. its length.
	Size int `json:"size"`
}

InlineTrustVector Refers to a trust vector "inline".

Instead of pointing (referencing) to an externally stored trust vector, it carries the contents of the trust vector within the reference object itself.

type InlineTrustVectorEntry

type InlineTrustVectorEntry struct {
	// I Denotes the peer.
	//
	// It is a zero-based index,
	// and must be less than the length of the enclosing trust vector.
	I int `json:"i"`

	// V Represents the (positive) amount of trust placed in peer `i`.
	V float64 `json:"v"`
}

InlineTrustVectorEntry Represents an entry in the local trust matrix.

Denotes that a trust is placed in a peer (`i`) by a specific amount (`v`).

type InlineTrustVectorScheme

type InlineTrustVectorScheme string

InlineTrustVectorScheme A fixed string `"inline"` to denote an inline reference.

const (
	InlineTrustVectorSchemeInline InlineTrustVectorScheme = "inline"
)

Defines values for InlineTrustVectorScheme.

type InvalidRequest

type InvalidRequest struct {
	// Message Describes the error in a human-readable message.
	//
	// It may be empty.
	Message string `json:"message"`
}

InvalidRequest defines model for InvalidRequest.

type InvalidRequestJSONResponse

type InvalidRequestJSONResponse struct {
	// Message Describes the error in a human-readable message.
	//
	// It may be empty.
	Message string `json:"message"`
}

type LocalTrustId

type LocalTrustId = string

LocalTrustId Denotes a local trust collection.

type LocalTrustIdParam

type LocalTrustIdParam = LocalTrustId

LocalTrustIdParam Denotes a local trust collection.

type LocalTrustRef

type LocalTrustRef struct {
	// Scheme Local trust reference scheme, akin to URI scheme.
	Scheme LocalTrustRefScheme `json:"scheme"`
	// contains filtered or unexported fields
}

LocalTrustRef defines model for LocalTrustRef.

func (LocalTrustRef) AsInlineLocalTrust

func (t LocalTrustRef) AsInlineLocalTrust() (InlineLocalTrust, error)

AsInlineLocalTrust returns the union data inside the LocalTrustRef as a InlineLocalTrust

func (LocalTrustRef) AsStoredLocalTrust

func (t LocalTrustRef) AsStoredLocalTrust() (StoredLocalTrust, error)

AsStoredLocalTrust returns the union data inside the LocalTrustRef as a StoredLocalTrust

func (*LocalTrustRef) FromInlineLocalTrust

func (t *LocalTrustRef) FromInlineLocalTrust(v InlineLocalTrust) error

FromInlineLocalTrust overwrites any union data inside the LocalTrustRef as the provided InlineLocalTrust

func (*LocalTrustRef) FromStoredLocalTrust

func (t *LocalTrustRef) FromStoredLocalTrust(v StoredLocalTrust) error

FromStoredLocalTrust overwrites any union data inside the LocalTrustRef as the provided StoredLocalTrust

func (LocalTrustRef) MarshalJSON

func (t LocalTrustRef) MarshalJSON() ([]byte, error)

func (*LocalTrustRef) MergeInlineLocalTrust

func (t *LocalTrustRef) MergeInlineLocalTrust(v InlineLocalTrust) error

MergeInlineLocalTrust performs a merge with any union data inside the LocalTrustRef, using the provided InlineLocalTrust

func (*LocalTrustRef) MergeStoredLocalTrust

func (t *LocalTrustRef) MergeStoredLocalTrust(v StoredLocalTrust) error

MergeStoredLocalTrust performs a merge with any union data inside the LocalTrustRef, using the provided StoredLocalTrust

func (*LocalTrustRef) UnmarshalJSON

func (t *LocalTrustRef) UnmarshalJSON(b []byte) error

type LocalTrustRefScheme

type LocalTrustRefScheme string

LocalTrustRefScheme Local trust reference scheme, akin to URI scheme.

const (
	LocalTrustRefSchemeInline LocalTrustRefScheme = "inline"
	LocalTrustRefSchemeStored LocalTrustRefScheme = "stored"
)

Defines values for LocalTrustRefScheme.

type RequestEditorFn

type RequestEditorFn func(ctx context.Context, req *http.Request) error

RequestEditorFn is the function signature for the RequestEditor callback function

type ServerInterface

type ServerInterface interface {
	// Compute EigenTrust scores
	// (POST /compute)
	Compute(ctx echo.Context) error
	// Compute EigenTrust scores, with execution statistics
	// (POST /compute-with-stats)
	ComputeWithStats(ctx echo.Context) error
	// Delete local trust
	// (DELETE /local-trust/{id})
	DeleteLocalTrust(ctx echo.Context, id LocalTrustIdParam) error
	// Retrieve local trust
	// (GET /local-trust/{id})
	GetLocalTrust(ctx echo.Context, id LocalTrustIdParam) error
	// Check for existence of local trust
	// (HEAD /local-trust/{id})
	HeadLocalTrust(ctx echo.Context, id LocalTrustIdParam) error
	// Update local trust
	// (PUT /local-trust/{id})
	UpdateLocalTrust(ctx echo.Context, id LocalTrustIdParam, params UpdateLocalTrustParams) error
}

ServerInterface represents all server handlers.

func NewStrictHandler

func NewStrictHandler(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc) ServerInterface

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) Compute

func (w *ServerInterfaceWrapper) Compute(ctx echo.Context) error

Compute converts echo context to params.

func (*ServerInterfaceWrapper) ComputeWithStats

func (w *ServerInterfaceWrapper) ComputeWithStats(ctx echo.Context) error

ComputeWithStats converts echo context to params.

func (*ServerInterfaceWrapper) DeleteLocalTrust

func (w *ServerInterfaceWrapper) DeleteLocalTrust(ctx echo.Context) error

DeleteLocalTrust converts echo context to params.

func (*ServerInterfaceWrapper) GetLocalTrust

func (w *ServerInterfaceWrapper) GetLocalTrust(ctx echo.Context) error

GetLocalTrust converts echo context to params.

func (*ServerInterfaceWrapper) HeadLocalTrust

func (w *ServerInterfaceWrapper) HeadLocalTrust(ctx echo.Context) error

HeadLocalTrust converts echo context to params.

func (*ServerInterfaceWrapper) UpdateLocalTrust

func (w *ServerInterfaceWrapper) UpdateLocalTrust(ctx echo.Context) error

UpdateLocalTrust converts echo context to params.

type StoredLocalTrust

type StoredLocalTrust struct {
	// Id Denotes a local trust collection.
	Id LocalTrustId `json:"id"`
}

StoredLocalTrust Refers to a local trust stored on the server.

Stored local trust is identified with its ID string.

type StrictHandlerFunc

type StrictHandlerFunc func(ctx echo.Context, args interface{}) (interface{}, error)

type StrictMiddlewareFunc

type StrictMiddlewareFunc func(f StrictHandlerFunc, operationID string) StrictHandlerFunc

type StrictServerImpl

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

func NewStrictServerImpl

func NewStrictServerImpl(logger zerolog.Logger) *StrictServerImpl

func (*StrictServerImpl) Compute

func (*StrictServerImpl) ComputeWithStats

func (*StrictServerImpl) DeleteLocalTrust

func (*StrictServerImpl) GetLocalTrust

func (*StrictServerImpl) HeadLocalTrust

func (*StrictServerImpl) UpdateLocalTrust

type StrictServerInterface

type StrictServerInterface interface {
	// Compute EigenTrust scores
	// (POST /compute)
	Compute(ctx context.Context, request ComputeRequestObject) (ComputeResponseObject, error)
	// Compute EigenTrust scores, with execution statistics
	// (POST /compute-with-stats)
	ComputeWithStats(ctx context.Context, request ComputeWithStatsRequestObject) (ComputeWithStatsResponseObject, error)
	// Delete local trust
	// (DELETE /local-trust/{id})
	DeleteLocalTrust(ctx context.Context, request DeleteLocalTrustRequestObject) (DeleteLocalTrustResponseObject, error)
	// Retrieve local trust
	// (GET /local-trust/{id})
	GetLocalTrust(ctx context.Context, request GetLocalTrustRequestObject) (GetLocalTrustResponseObject, error)
	// Check for existence of local trust
	// (HEAD /local-trust/{id})
	HeadLocalTrust(ctx context.Context, request HeadLocalTrustRequestObject) (HeadLocalTrustResponseObject, error)
	// Update local trust
	// (PUT /local-trust/{id})
	UpdateLocalTrust(ctx context.Context, request UpdateLocalTrustRequestObject) (UpdateLocalTrustResponseObject, error)
}

StrictServerInterface represents all server handlers.

type TrustVectorRef

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

TrustVectorRef Refers to a trust vector.

func (TrustVectorRef) AsInlineTrustVector

func (t TrustVectorRef) AsInlineTrustVector() (InlineTrustVector, error)

AsInlineTrustVector returns the union data inside the TrustVectorRef as a InlineTrustVector

func (*TrustVectorRef) FromInlineTrustVector

func (t *TrustVectorRef) FromInlineTrustVector(v InlineTrustVector) error

FromInlineTrustVector overwrites any union data inside the TrustVectorRef as the provided InlineTrustVector

func (TrustVectorRef) MarshalJSON

func (t TrustVectorRef) MarshalJSON() ([]byte, error)

func (*TrustVectorRef) MergeInlineTrustVector

func (t *TrustVectorRef) MergeInlineTrustVector(v InlineTrustVector) error

MergeInlineTrustVector performs a merge with any union data inside the TrustVectorRef, using the provided InlineTrustVector

func (*TrustVectorRef) UnmarshalJSON

func (t *TrustVectorRef) UnmarshalJSON(b []byte) error

type UpdateLocalTrust200Response

type UpdateLocalTrust200Response struct {
}

func (UpdateLocalTrust200Response) VisitUpdateLocalTrustResponse

func (response UpdateLocalTrust200Response) VisitUpdateLocalTrustResponse(w http.ResponseWriter) error

type UpdateLocalTrust201Response

type UpdateLocalTrust201Response struct {
}

func (UpdateLocalTrust201Response) VisitUpdateLocalTrustResponse

func (response UpdateLocalTrust201Response) VisitUpdateLocalTrustResponse(w http.ResponseWriter) error

type UpdateLocalTrust400JSONResponse

type UpdateLocalTrust400JSONResponse struct{ InvalidRequestJSONResponse }

func (UpdateLocalTrust400JSONResponse) VisitUpdateLocalTrustResponse

func (response UpdateLocalTrust400JSONResponse) VisitUpdateLocalTrustResponse(w http.ResponseWriter) error

type UpdateLocalTrustJSONRequestBody

type UpdateLocalTrustJSONRequestBody = LocalTrustRef

UpdateLocalTrustJSONRequestBody defines body for UpdateLocalTrust for application/json ContentType.

type UpdateLocalTrustParams

type UpdateLocalTrustParams struct {
	// Merge Controls behavior if a local trust exists under the same ID.
	//
	// If false (default), the local trust ref contents replaces
	// the existing one under the same ID, if any.
	// If true, the local trust ref contents are merged
	// into the existing one under the same ID.
	Merge *bool `form:"merge,omitempty" json:"merge,omitempty"`
}

UpdateLocalTrustParams defines parameters for UpdateLocalTrust.

type UpdateLocalTrustRequestObject

type UpdateLocalTrustRequestObject struct {
	Id     LocalTrustIdParam `json:"id,omitempty"`
	Params UpdateLocalTrustParams
	Body   *UpdateLocalTrustJSONRequestBody
}

type UpdateLocalTrustResponse

type UpdateLocalTrustResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON400      *struct {
		// Message Describes the error in a human-readable message.
		//
		// It may be empty.
		Message string `json:"message"`
	}
}

func ParseUpdateLocalTrustResponse

func ParseUpdateLocalTrustResponse(rsp *http.Response) (*UpdateLocalTrustResponse, error)

ParseUpdateLocalTrustResponse parses an HTTP response from a UpdateLocalTrustWithResponse call

func (UpdateLocalTrustResponse) Status

func (r UpdateLocalTrustResponse) Status() string

Status returns HTTPResponse.Status

func (UpdateLocalTrustResponse) StatusCode

func (r UpdateLocalTrustResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type UpdateLocalTrustResponseObject

type UpdateLocalTrustResponseObject interface {
	VisitUpdateLocalTrustResponse(w http.ResponseWriter) error
}

Jump to

Keyboard shortcuts

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