cardano-wallet-core-2022.7.1: The Wallet Backend for a Cardano node.
Safe Haskell None
Language Haskell2010

Cardano.Wallet.Registry

Synopsis

Worker Registry

data WorkerRegistry key resource Source #

A registry to keep track of worker threads and acquired resources.

empty :: Ord key => IO ( WorkerRegistry key resource) Source #

Construct a new empty registry

lookup :: ( MonadIO m, Ord key) => WorkerRegistry key resource -> key -> m ( Maybe ( Worker key resource)) Source #

Lookup the registry for a given worker

register :: forall resource ctx key msg. ( Ord key, key ~ WorkerKey ctx, msg ~ WorkerMsg ctx, HasLogger IO ( WorkerLog key msg) ctx, HasWorkerCtx resource ctx) => WorkerRegistry key resource -> ctx -> key -> MkWorker key resource msg ctx -> IO ( Maybe ( Worker key resource)) Source #

Register a new worker for a given key.

A worker maintains an acquired resource. It expects a task as an argument and will terminate as soon as its task is over. In practice, we provide a never-ending task that keeps the worker alive forever.

Returns Nothing if the worker fails to acquire the necessary resource or terminates unexpectedly before entering its main action.

unregister :: Ord key => WorkerRegistry key resource -> key -> IO () Source #

Unregister a worker from the registry, terminating the running task.

Worker

data Worker key resource Source #

A worker which holds and manipulate a particular acquired resource. That resource can be, for example, a handle to a database connection.

Instances

Instances details
Generic ( Worker key resource) Source #
Instance details

Defined in Cardano.Wallet.Registry

Associated Types

type Rep ( Worker key resource) :: Type -> Type Source #

Methods

from :: Worker key resource -> Rep ( Worker key resource) x Source #

to :: Rep ( Worker key resource) x -> Worker key resource Source #

type Rep ( Worker key resource) Source #
Instance details

Defined in Cardano.Wallet.Registry

type Rep ( Worker key resource) = D1 (' MetaData "Worker" "Cardano.Wallet.Registry" "cardano-wallet-core-2022.7.1-AGKhlyz9liLKN3QqZD1gj" ' False ) ( C1 (' MetaCons "Worker" ' PrefixI ' True ) ( S1 (' MetaSel (' Just "workerId") ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 key) :*: ( S1 (' MetaSel (' Just "workerThread") ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 ThreadId ) :*: S1 (' MetaSel (' Just "workerResource") ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 resource))))

data MkWorker key resource msg ctx Source #

Constructors

MkWorker

Fields

workerId :: Worker key resource -> key Source #

workerResource :: Worker key resource -> resource Source #

Context

class HasType resource ( WorkerCtx ctx) => HasWorkerCtx resource ctx where Source #

A class to link an existing context to a worker context.

Methods

hoistResource :: resource -> ( WorkerMsg ctx -> WorkerLog ( WorkerKey ctx) ( WorkerMsg ctx)) -> ctx -> WorkerCtx ctx Source #

Logging

data WorkerLog key msg Source #

Log messages relating to a registry worker thread.

Instances

Instances details
( Eq key, Eq msg) => Eq ( WorkerLog key msg) Source #
Instance details

Defined in Cardano.Wallet.Registry

( Show key, Show msg) => Show ( WorkerLog key msg) Source #
Instance details

Defined in Cardano.Wallet.Registry

( ToText key, ToText msg) => ToText ( WorkerLog key msg) Source #
Instance details

Defined in Cardano.Wallet.Registry

HasPrivacyAnnotation ( WorkerLog key msg) Source #
Instance details

Defined in Cardano.Wallet.Registry

Methods

getPrivacyAnnotation :: WorkerLog key msg -> PrivacyAnnotation

HasSeverityAnnotation msg => HasSeverityAnnotation ( WorkerLog key msg) Source #
Instance details

Defined in Cardano.Wallet.Registry

Methods

getSeverityAnnotation :: WorkerLog key msg -> Severity