fact

package
v0.0.0-...-b2c82e1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterHandlers

func RegisterHandlers(r *echo.Group, service Service, cService connection.Service, logger log.Logger)

RegisterHandlers sets up the routing of the HTTP handlers.

Types

type CreateFactRequest

type CreateFactRequest struct {
	Facts []FactToIssue `json:"facts"`
}

CreateFactRequest represents an fact creation request.

func (CreateFactRequest) Validate

func (m CreateFactRequest) Validate() *response.Error

Validate validates the CreateFactRequest fields.

type CreateFactRequestDoc

type CreateFactRequestDoc struct {
	Facts []struct {
		Key    string `json:"key"`
		Value  string `json:"value"`
		Source string `json:"source"`
		Group  *struct {
			Name string `json:"name"`
			Icon string `json:"icon"`
		} `json:"group,omitempty"`
		Type string `json:"type,omitempty"`
	} `json:"facts"`
}

WARNING: Do not use for code purposes, this is only used to generate the documentation for the openapi, which seems to be broken for nested structs.

type ExtFact

type ExtFact struct {
	ISS       string    `json:"iss"`
	Key       string    `json:"key"`
	Source    string    `json:"source"`
	CreatedAt time.Time `json:"created_at"`
	Values    []string  `json:"values"`
}

func NewExtFact

func NewExtFact(f Fact) ExtFact

type ExtListResponse

type ExtListResponse struct {
	Page       int       `json:"page"`
	PerPage    int       `json:"per_page"`
	PageCount  int       `json:"page_count"`
	TotalCount int       `json:"total_count"`
	Items      []ExtFact `json:"items"`
}

type Fact

type Fact struct {
	entity.Fact
	Attestations []entity.Attestation `json:"attestations"`
}

Fact represents the data about an fact.

type FactToIssue

type FactToIssue struct {
	Key        string          `json:"key"`
	Value      string          `json:"value"`
	Source     string          `json:"source"`
	Group      *fact.FactGroup `json:"group,omitempty"`
	Type       string          `json:"type,omitempty"`
	ExpTimeout *time.Duration  `json:"exp_timeout,omitempty"`
}

type IssuerService

type IssuerService interface {
	Issue(selfID string, facts []fact.FactToIssue, viewers []string) error
}

RequesterService service to manage sending and receiving fact requests

type Repository

type Repository interface {
	// Get returns the fact with the specified fact ID.
	Get(ctx context.Context, connectionID int, id string) (entity.Fact, error)
	// Count returns the number of facts.
	Count(ctx context.Context, conn int, source, fact string) (int, error)
	// Query returns the list of facts with the given offset and limit.
	Query(ctx context.Context, conn int, source, fact string, offset, limit int) ([]entity.Fact, error)
	// Create saves a new fact in the storage.
	Create(ctx context.Context, fact entity.Fact) error
	// Update updates the fact with given ID in the storage.
	Update(ctx context.Context, fact entity.Fact) error
	// Delete removes the fact with given ID from the storage.
	Delete(ctx context.Context, connID int, id string) error
	// SetStatus updates the fact identified by the given id with the given status.
	SetStatus(ctx context.Context, connID int, id string, status string) error
	// FindByRequestID returns the fact with the specified request ID.
	FindByRequestID(ctx context.Context, connectionID *int, requestID string) ([]entity.Fact, error)
}

Repository encapsulates the logic to access facts from the data source.

func NewRepository

func NewRepository(db *dbcontext.DB, logger log.Logger) Repository

NewRepository creates a new fact repository

type Service

type Service interface {
	Get(ctx context.Context, connectionID int, id string) (Fact, error)
	Query(ctx context.Context, conn int, source, fact string, offset, limit int) ([]Fact, error)
	Count(ctx context.Context, conn int, source, fact string) (int, error)
	Create(ctx context.Context, appID, selfID string, connection int, input CreateFactRequest) error
	Delete(ctx context.Context, connID int, id string) error
}

Service encapsulates usecase logic for facts.

func NewService

func NewService(repo Repository, atRepo attestation.Repository, runner support.SelfClientGetter, logger log.Logger) Service

NewService creates a new fact service.

Jump to

Keyboard shortcuts

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