pkg

package
v0.0.0-...-b4e6ae9 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

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

Application is the main application struct. It creates postgres datastore and consumer, and connects them together.

func NewApplication

func NewApplication(params ApplicationParams) (*Application, error)

func (*Application) Start

func (a *Application) Start(ctx context.Context) error

Start starts the application by starting the gossipsub consumer.

func (*Application) Stop

func (a *Application) Stop(ctx context.Context) error

Stop stops the application by stopping the gossipsub consumer and closing the datastore.

type ApplicationParams

type ApplicationParams struct {
	PostgresDatastoreParams
	Libp2pHost host.Host
}

type Consumer

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

Consumer registers to the gossipsub topic and inserts the received job info into the datastore.

func NewConsumer

func NewConsumer(params ConsumerParams) *Consumer

func (*Consumer) Start

func (c *Consumer) Start(ctx context.Context) (err error)

func (*Consumer) Stop

func (c *Consumer) Stop(ctx context.Context) error

type ConsumerParams

type ConsumerParams struct {
	Libp2pHost host.Host
	Datastore  *PostgresDatastore
}

type PostgresDatastore

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

PostgresDatastore is a postgres datastore. It supports migration of the database schema using go-migrate.

func NewPostgresDatastore

func NewPostgresDatastore(params PostgresDatastoreParams) (*PostgresDatastore, error)

func (*PostgresDatastore) Close

func (d *PostgresDatastore) Close() error

func (*PostgresDatastore) InsertJobInfo

func (d *PostgresDatastore) InsertJobInfo(ctx context.Context, envelope jobinfo.Envelope) error

func (*PostgresDatastore) MigrateDown

func (d *PostgresDatastore) MigrateDown() error

func (*PostgresDatastore) MigrateUp

func (d *PostgresDatastore) MigrateUp() error

type PostgresDatastoreParams

type PostgresDatastoreParams struct {
	Host        string
	Port        int
	Database    string
	User        string
	Password    string
	SSLMode     string
	AutoMigrate bool
}

Jump to

Keyboard shortcuts

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