brokerdiscovery

package
v0.0.0-...-365054f Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRegistry

func NewRegistry(connection nats.Connection) *registryBroker

NewRegistry create an instance of Broker registryBroker

Types

type ProposalReducer

type ProposalReducer func(proposal market.ServiceProposal) bool

ProposalReducer proposal match function

type ProposalStorage

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

ProposalStorage represents table of currently active proposals in Mysterium Discovery

func NewStorage

func NewStorage(eventPublisher eventbus.Publisher) *ProposalStorage

NewStorage creates new instance of ProposalStorage

func (*ProposalStorage) AddProposal

func (s *ProposalStorage) AddProposal(proposals ...market.ServiceProposal)

AddProposal appends given proposal to storage

func (*ProposalStorage) Countries

func (s *ProposalStorage) Countries(filter *proposal.Filter) (map[string]int, error)

Countries fetches currently active service proposals from storage by given filter

func (*ProposalStorage) FindProposals

func (s *ProposalStorage) FindProposals(filter *proposal.Filter) ([]market.ServiceProposal, error)

FindProposals fetches currently active service proposals from storage by given filter

func (*ProposalStorage) GetProposal

GetProposal returns proposal from storage

func (*ProposalStorage) HasProposal

func (s *ProposalStorage) HasProposal(id market.ProposalID) bool

HasProposal checks if proposal exists in storage

func (*ProposalStorage) MatchProposals

func (s *ProposalStorage) MatchProposals(match ProposalReducer) ([]market.ServiceProposal, error)

MatchProposals fetches currently active service proposals from storage by match function

func (*ProposalStorage) Proposals

func (s *ProposalStorage) Proposals() []market.ServiceProposal

Proposals returns list of proposals in storage

func (*ProposalStorage) RemoveProposal

func (s *ProposalStorage) RemoveProposal(id market.ProposalID)

RemoveProposal removes proposal from storage

func (*ProposalStorage) Set

func (s *ProposalStorage) Set(proposals []market.ServiceProposal)

Set puts given list proposals to storage

type Repository

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

Repository provides proposals from the broker.

func NewRepository

func NewRepository(
	connection nats.Connection,
	storage *ProposalStorage,
	proposalTimeoutInterval time.Duration,
	proposalCheckInterval time.Duration,
) *Repository

NewRepository constructs a new proposal repository (backed by the broker).

func (*Repository) Countries

func (r *Repository) Countries(filter *proposal.Filter) (map[string]int, error)

Countries returns proposals per country matching the filter.

func (*Repository) Proposal

Proposal returns a single proposal by its ID.

func (*Repository) Proposals

func (r *Repository) Proposals(filter *proposal.Filter) ([]market.ServiceProposal, error)

Proposals returns proposals matching the filter.

func (*Repository) Start

func (r *Repository) Start() error

Start begins proposals synchronization to storage

func (*Repository) Stop

func (r *Repository) Stop()

Stop ends proposals synchronization to storage

Jump to

Keyboard shortcuts

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