userstorage

package
v0.0.0-...-92ca402 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Right     = 0
	Wrong     = 1
	Honest    = 2
	Dishonest = 3
	Abstained = 4
)

Variables

View Source
var SubjectClaimMappingError = &tracer.Error{
	Kind: "SubjectClaimMappingError",
	Desc: "The request expects a mapping between external subject claim and internal user ID. No mapping was found. Therefore the request failed.",
}
View Source
var UserNameLengthError = &tracer.Error{
	Kind: "UserNameLengthError",
	Desc: "The request expects the user name to have between 2 and 30 characters. The user name was not found to have between 2 and 30 characters. Therefore the request failed.",
}
View Source
var UserNotFoundError = &tracer.Error{
	Kind: "UserNotFoundError",
	Desc: "The request expects a user object to exist. The user object was not found to exist. Therefore the request failed.",
}
View Source
var UserSubjectEmptyError = &tracer.Error{
	Kind: "UserSubjectEmptyError",
	Desc: "The request expects the user's subject claim not to be empty. The user's subject claim was found to be empty. Therefore the request failed.",
}
View Source
var UserSummaryError = &tracer.Error{
	Kind: "UserSummaryError",
	Desc: "The request expects the user's summary to have exactly 5 elements. The user's summary was not found to have 5 elements. Therefore the request failed.",
}

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// CreateUser persists a new user object given the provided subject claim, if
	// none does exist already. Create is therefore idempotent and yields the same
	// persisted user object given the same provided subject claim.
	//
	//     @inp[0] the user object providing user specific information
	//     @out[0] the user object mapped to the given subject claim
	//
	CreateUser(*Object) (*Object, error)

	// DeleteReputation removes the lowest reputation users from the limited
	// reputation index.
	DeleteReputation() error

	// SearchReputation returns the user objects within the given pagination range in
	// reversed order of user reputation scores. Given the indexed users [A B C D E],
	// the first page [0 3] returns the highest reputation users [C D E].
	//
	//     @inp[0] the start paging pointer defining the beginning of the page
	//     @inp[1] the stop paging pointer defining the end of the page
	//     @out[0] the list of user objects within the given pagination range
	//
	SearchReputation(int, int) ([]*Object, error)

	// SearchSubject returns the user object mapped to the given subject claim, it
	// it exists. SearchSubject will return an error if there is no user mapping
	// already persisted between the external subject claim and the internal user
	// ID.
	//
	//     @inp[0] the external subject claim mapped to our internal user ID
	//     @out[0] the user object mapped to the given subject claim
	//
	SearchSubject(string) (*Object, error)

	// SearchUser returns the user objects matching the given user IDs.
	//
	//     @inp[0] the user IDs to search for
	//     @out[0] the list of user objects matching the given user IDs
	//
	SearchUser([]objectid.ID) ([]*Object, error)

	// UpdateReputation ensures the referenced IDs of the given user objects are
	// properly reflected in the reputation specific UserReputation index. This
	// form of indexing enables us to search for the users with the highest
	// reputation on the Uvio platform.
	//
	//     @inp[0] the user objects to add to the UserReputation index
	//
	UpdateReputation(inp []*Object) error

	// UpdateUser modifies the given user objects in the underlying storage.
	//
	//     @inp[0] the user objects to update
	//
	UpdateUser([]*Object) error
}

func Fake

func Fake() Interface

type Object

type Object struct {
	// Created is the time at which the user got created.
	Created time.Time `json:"created,omitempty"`
	// ID is the internal ID of the user being created.
	ID objectid.ID `json:"id,omitempty"`
	// Imag is the URL pointing to the user's profile picture.
	Image objectfield.String `json:"image,omitempty"`
	// Name is the user name.
	Name objectfield.String `json:"name,omitempty"`
	// Pointer is the user's note pointer, which tracks the user's latest seen
	// notification.
	Pointer string `json:"pointer,omitempty"`
	// Subject is the list of external subject claims mapped to the user being
	// created.
	Subject []string `json:"subject,omitempty"`
	// Summary is the collection of user specific metrics on competence and
	// integrity.
	//
	//     [0] the number of times this user has been right
	//     [1] the number of times this user has been wrong
	//     [2] the number of times this user has been honest
	//     [3] the number of times this user has been dishonest
	//     [4] the number of times this user has denied to vote
	//
	Summary []float64 `json:"summary,omitempty"`
}

func (*Object) Competence

func (o *Object) Competence() float64

func (*Object) Integrity

func (o *Object) Integrity() float64

func (*Object) Reputation

func (o *Object) Reputation() float64

func (*Object) Verify

func (o *Object) Verify() error

type Redigo

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

func NewRedigo

func NewRedigo(c RedigoConfig) *Redigo

func (*Redigo) CreateUser

func (r *Redigo) CreateUser(inp *Object) (*Object, error)

func (*Redigo) DeleteReputation

func (r *Redigo) DeleteReputation() error

func (*Redigo) SearchReputation

func (r *Redigo) SearchReputation(beg int, end int) ([]*Object, error)

func (*Redigo) SearchSubject

func (r *Redigo) SearchSubject(sub string) (*Object, error)

func (*Redigo) SearchUser

func (r *Redigo) SearchUser(use []objectid.ID) ([]*Object, error)

func (*Redigo) UpdateReputation

func (r *Redigo) UpdateReputation(inp []*Object) error

func (*Redigo) UpdateUser

func (r *Redigo) UpdateUser(inp []*Object) error

type RedigoConfig

type RedigoConfig struct {
	Log logger.Interface
	Red redigo.Interface
}

Jump to

Keyboard shortcuts

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