Documentation ¶
Index ¶
- func InitEscrows(ctx context.Context, s *publisherServer, caches []*ccmsg.CacheDescription) error
- func UpdateKnownCaches(ctx context.Context, s *publisherServer, caches []*ccmsg.CacheDescription) error
- type Application
- type BundleEntryParams
- type BundleGenerator
- type BundleParams
- type ConfigFile
- type ContentPublisher
- func (p *ContentPublisher) AddEscrow(escrow *Escrow) error
- func (p *ContentPublisher) AddEscrowToDatabase(ctx context.Context, escrow *Escrow) error
- func (p *ContentPublisher) HandleContentRequest(ctx context.Context, req *ccmsg.ContentRequest) ([]*ccmsg.TicketBundle, error)
- func (p *ContentPublisher) LoadFromDatabase(ctx context.Context) (int, error)
- func (p *ContentPublisher) NewEscrow(info *ccmsg.EscrowInfo) (*Escrow, error)
- type Escrow
- type ParticipatingCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitEscrows ¶
func InitEscrows(ctx context.Context, s *publisherServer, caches []*ccmsg.CacheDescription) error
InitEscrows is for local test-networks self-assembly
func UpdateKnownCaches ¶
func UpdateKnownCaches(ctx context.Context, s *publisherServer, caches []*ccmsg.CacheDescription) error
Types ¶
type Application ¶
type Application interface { common.StarterShutdowner }
An Application is the top-level content publisher. It takes a configuration struct. Its children are the several protocol servers (that deal with clients, caches, and so forth).
func NewApplication ¶
func NewApplication(l *logrus.Logger, p *ContentPublisher, db *sql.DB, conf *ConfigFile, r *ledgerclient.Replicator) (Application, error)
NewApplication constructs a new publisher application.
type BundleEntryParams ¶
type BundleEntryParams struct { TicketNo uint64 ChunkIdx uint32 ChunkID common.ChunkID Cache ParticipatingCache }
type BundleGenerator ¶
type BundleGenerator struct { PuzzleParams *colocationpuzzle.Parameters Signer batchsignature.BatchSigner // contains filtered or unexported fields }
func NewBundleGenerator ¶
func NewBundleGenerator(l *logrus.Logger, signer batchsignature.BatchSigner) *BundleGenerator
func (*BundleGenerator) GenerateTicketBundle ¶
func (gen *BundleGenerator) GenerateTicketBundle(bp *BundleParams) (*ccmsg.TicketBundle, error)
XXX: Attach this function to a struct containing configuration data (like e.g. puzzle parameters), or add those things as arguments.
type BundleParams ¶
type BundleParams struct { Escrow *Escrow // XXX: Do we need this? ObjectID common.ObjectID // This is a per-escrow value. Entries []BundleEntryParams PlaintextChunks [][]byte RequestSequenceNo uint64 ClientPublicKey ed25519.PublicKey }
BundleParams is everything necessary to generate a complete TicketBundle message.
type ConfigFile ¶
type ConfigFile struct { Origin string PublisherAddr string GrpcAddr string StatusAddr string BootstrapAddr string LedgerAddr string DefaultCacheDuration time.Duration SyncInterval time.Duration Insecure bool UpstreamURL string `json:"upstreamURL"` Database string `json:"database"` }
ConfigFile is the file the publisher is configured from.
type ContentPublisher ¶
type ContentPublisher struct { PublisherAddr string // contains filtered or unexported fields }
ContentPublisher is the main state for the publisher daemon.
During startup the CLI entry point populates this by calling LoadFromDatabase, and the intent is that from that point all state is cached in RAM but the database is the source of truth with soft degradation. Some code may be inconsistent with this design principle - please fix if noticed. Reasoning:
- for a single escrow cache counts are anticipated to be O(100's)
- for a single publisher escrow counts are anticipated to be O(10's)
- at least for the early / medium term: the network should support a great many publishers and a great many escrows of course, but this component itself is working on a 'fits in RAM' problem and thus we can optimise it to be low latency
- the publisher needs to be available for clients to obtain content, and AWS performs regular outages to postgreSQL as part of regular maintenance and operations.
- once truth is established the cached in RAM data can be operated on very quickly e.g. the contents of an escrow cannot change after establishment
func NewContentPublisher ¶
func NewContentPublisher(l *logrus.Logger, publisherAddr string, catalog catalog.ContentCatalog, signer ed25519.PrivateKey) (*ContentPublisher, error)
func (*ContentPublisher) AddEscrow ¶
func (p *ContentPublisher) AddEscrow(escrow *Escrow) error
AddEscrow - internal helper? XXX: Temporary (we have nothing syncing from DB back to memory or maintaining memory integrity)
func (*ContentPublisher) AddEscrowToDatabase ¶
func (p *ContentPublisher) AddEscrowToDatabase(ctx context.Context, escrow *Escrow) error
func (*ContentPublisher) HandleContentRequest ¶
func (p *ContentPublisher) HandleContentRequest(ctx context.Context, req *ccmsg.ContentRequest) ([]*ccmsg.TicketBundle, error)
HandleContentRequest serves ticket bundles to clients.
This is only exported for integration_test.go.
func (*ContentPublisher) LoadFromDatabase ¶
func (p *ContentPublisher) LoadFromDatabase(ctx context.Context) (int, error)
func (*ContentPublisher) NewEscrow ¶
func (p *ContentPublisher) NewEscrow(info *ccmsg.EscrowInfo) (*Escrow, error)
The info object does not need to have its keys populated.
type Escrow ¶
type Escrow struct { Publisher *ContentPublisher Inner models.Escrow Caches []*ParticipatingCache // contains filtered or unexported fields }
func CreateEscrow ¶
func CreateEscrow(ctx context.Context, publisher *ContentPublisher, cacheDescriptions []*ccmsg.CacheDescription) (*Escrow, error)
func (*Escrow) CalculateLookup ¶
CalculateLookup calculates chunk lookup tables for maglev style chunk allocations This can fail if there are not enough caches. This routine operates off populated structs - load from database before calling
type ParticipatingCache ¶
func OfferEscrow ¶
func OfferEscrow(ctx context.Context, l *logrus.Logger, offerRequest *ccmsg.EscrowOfferRequest, descr *ccmsg.CacheDescription) (*ParticipatingCache, error)
func (ParticipatingCache) Inet6Addr ¶
func (p ParticipatingCache) Inet6Addr() net.IP
func (ParticipatingCache) Inetaddr ¶
func (p ParticipatingCache) Inetaddr() net.IP
func (ParticipatingCache) Port ¶
func (p ParticipatingCache) Port() uint32
func (ParticipatingCache) PublicKey ¶
func (p ParticipatingCache) PublicKey() ed25519.PublicKey