opinion

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: Apache-2.0, BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertOpinionToFloat64 added in v0.5.5

func ConvertOpinionToFloat64(x Opinion) float64

ConvertOpinionToFloat64 converts the given Opinion to an float64.

func ConvertOpinionToInt32ForLiveFeed added in v0.5.5

func ConvertOpinionToInt32ForLiveFeed(x Opinion) int32

ConvertOpinionToInt32ForLiveFeed converts the given Opinion to an int32.

func ConvertOpinionsToInts32ForLiveFeed added in v0.5.5

func ConvertOpinionsToInts32ForLiveFeed(opinions []Opinion) []int32

ConvertOpinionsToInts32ForLiveFeed converts the given slice of Opinion to a slice of int32.

Types

type Opinion

type Opinion byte

Opinion is an opinion about a given thing.

const (
	// Like defines a Like opinion.
	Like Opinion = 1 << 0
	// Dislike defines a Dislike opinion.
	Dislike Opinion = 1 << 1
	// Unknown defines an unknown opinion.
	Unknown Opinion = 1 << 2
)

func ConvertInt32Opinion

func ConvertInt32Opinion(x int32) Opinion

ConvertInt32Opinion converts the given int32 to an Opinion.

func ConvertInts32ToOpinions

func ConvertInts32ToOpinions(opinions []int32) []Opinion

ConvertInts32ToOpinions converts the given slice of int32 to a slice of Opinion.

func (Opinion) String

func (o Opinion) String() string

type OpinionGiver

type OpinionGiver interface {
	// Query queries the OpinionGiver for its opinions on the given IDs.
	// The passed in context can be used to signal cancellation of the query.
	Query(ctx context.Context, conflictIDs []string, timestampIDs []string, delayedRoundStart ...time.Duration) (Opinions, error)
	// ID returns the ID of the opinion giver.
	ID() identity.ID
	Mana() float64
}

OpinionGiver gives opinions about the given IDs.

type OpinionGiverFunc

type OpinionGiverFunc func() ([]OpinionGiver, error)

OpinionGiverFunc is a function which gives a slice of OpinionGivers or an error.

type Opinions

type Opinions []Opinion

Opinions is a slice of Opinion.

type OwnWeightRetriever added in v0.5.5

type OwnWeightRetriever func() (float64, error)

OwnWeightRetriever is a function which gives your own weight used in voting mechanism

type QueriedOpinions

type QueriedOpinions struct {
	// The ID of the opinion giver.
	OpinionGiverID string `json:"opinion_giver_id"`
	// The map of IDs to opinions.
	Opinions map[string]Opinion `json:"opinions"`
	// The amount of times the opinion giver's opinion has counted.
	// Usually this number is 1 but due to randomization of the queried opinion givers,
	// the same opinion giver's opinions might be taken into account multiple times.
	TimesCounted int `json:"times_counted"`
}

QueriedOpinions represents queried opinions from a given opinion giver.

Jump to

Keyboard shortcuts

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