discovery

package
v0.0.0-...-c97221a Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AppTopicProposalAdded represents newly announced proposal
	AppTopicProposalAdded = "ProposalAdded"
	// AppTopicProposalUpdated represents re-announced proposal
	AppTopicProposalUpdated = "ProposalUpdated"
	// AppTopicProposalRemoved represents newly de-announced proposal
	AppTopicProposalRemoved = "ProposalRemoved"
	// AppTopicProposalAnnounce represent proposal events topic.
	AppTopicProposalAnnounce = "proposalEvent"
)

Topic represents the different topics a consumer can subscribe to

Variables

This section is empty.

Functions

func NewRegistry

func NewRegistry(registries ...ProposalRegistry) *registryComposite

NewRegistry creates an instance of composite registry

func NewRepository

func NewRepository() *repository

NewRepository constructs a new composite repository.

func NewWorker

func NewWorker(workers ...Worker) *workerComposite

NewWorker creates an instance of composite worker.

Types

type Discovery

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

Discovery structure holds discovery service state

func NewService

func NewService(
	identityRegistry registry.IdentityRegistry,
	proposalRegistry ProposalRegistry,
	proposalPingTTL time.Duration,
	signerCreate identity.SignerFactory,
	eventBus eventbus.EventBus,
) *Discovery

NewService creates new discovery service

func (*Discovery) Start

func (d *Discovery) Start(ownIdentity identity.Identity, proposal func() market.ServiceProposal)

Start launches discovery service

func (*Discovery) Stop

func (d *Discovery) Stop()

Stop stops discovery loop

func (*Discovery) Wait

func (d *Discovery) Wait()

Wait wait for proposal announcements to stop / unregister

type PriceInfoProvider

type PriceInfoProvider interface {
	GetCurrentPrice(nodeType string, country string, serviceType string) (market.Price, error)
}

PriceInfoProvider allows to fetch the current pricing for services.

type PricedServiceProposalRepository

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

PricedServiceProposalRepository enriches proposals with price data as pricing data is not available on raw proposals.

func NewPricedServiceProposalRepository

func NewPricedServiceProposalRepository(baseRepo proposal.Repository, pip PriceInfoProvider, filterPresets proposal.FilterPresetRepository) *PricedServiceProposalRepository

NewPricedServiceProposalRepository returns a new instance of PricedServiceProposalRepository.

func (*PricedServiceProposalRepository) Countries

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

Countries fetches number of proposals per country from base repository.

func (*PricedServiceProposalRepository) EnrichProposalWithPrice

EnrichProposalWithPrice adds pricing info to service proposal.

func (*PricedServiceProposalRepository) Proposal

Proposal fetches the proposal from base repository and enriches it with pricing data.

func (*PricedServiceProposalRepository) Proposals

Proposals fetches proposals from base repository and enriches them with pricing data.

type ProposalRegistry

type ProposalRegistry interface {
	RegisterProposal(proposal market.ServiceProposal, signer identity.Signer) error
	PingProposal(proposal market.ServiceProposal, signer identity.Signer) error
	UnregisterProposal(proposal market.ServiceProposal, signer identity.Signer) error
}

ProposalRegistry defines methods for proposal lifecycle - registration, keeping up to date, removal

type Status

type Status int

Status describes stage of proposal registration

const (
	IdentityUnregistered Status = iota
	WaitingForRegistration
	IdentityRegisterFailed
	RegisterProposal
	PingProposal
	UnregisterProposal
	UnregisterProposalFailed
	ProposalUnregistered
	StatusUndefined
)

Proposal registration stages

type Worker

type Worker interface {
	Start() error
	Stop()
}

Worker continuously runs discovery process in node's background.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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