Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class PABContract contract where
- type ContractDef contract
- type State contract
- serialisableState :: Proxy contract -> State contract -> ContractResponse Value Value PABResp PABReq
- requests :: forall contract. PABContract contract => State contract -> [Request PABReq]
- data ContractEffect t r where
- InitialState :: PABContract t => ContractInstanceId -> ContractDef t -> ContractEffect t (State t)
- UpdateContract :: PABContract t => ContractInstanceId -> ContractDef t -> State t -> Response PABResp -> ContractEffect t (State t)
- initialState :: forall t effs. (Member (ContractEffect t) effs, PABContract t) => ContractInstanceId -> ContractDef t -> Eff effs (State t)
- updateContract :: forall t effs. (Member (ContractEffect t) effs, PABContract t) => ContractInstanceId -> ContractDef t -> State t -> Response PABResp -> Eff effs (State t)
- data ContractStore t r where
- PutStartInstance :: ContractActivationArgs (ContractDef t) -> ContractInstanceId -> ContractStore t ()
- PutState :: ContractActivationArgs (ContractDef t) -> ContractInstanceId -> State t -> ContractStore t ()
- GetState :: ContractInstanceId -> ContractStore t (State t)
- PutStopInstance :: ContractInstanceId -> ContractStore t ()
- GetContracts :: Maybe ContractActivityStatus -> ContractStore t (Map ContractInstanceId (ContractActivationArgs (ContractDef t)))
- DeleteState :: ContractInstanceId -> ContractStore t ()
- putState :: forall t effs. Member (ContractStore t) effs => ContractActivationArgs (ContractDef t) -> ContractInstanceId -> State t -> Eff effs ()
- getState :: forall t effs. Member (ContractStore t) effs => ContractInstanceId -> Eff effs (State t)
- getDefinition :: forall t effs. Member (ContractStore t) effs => ContractInstanceId -> Eff effs (Maybe (ContractActivationArgs (ContractDef t)))
- getActiveContracts :: forall t effs. Member (ContractStore t) effs => Eff effs (Map ContractInstanceId (ContractActivationArgs (ContractDef t)))
- getContracts :: forall t effs. Member (ContractStore t) effs => Maybe ContractActivityStatus -> Eff effs (Map ContractInstanceId (ContractActivationArgs (ContractDef t)))
- putStartInstance :: forall t effs. Member (ContractStore t) effs => ContractActivationArgs (ContractDef t) -> ContractInstanceId -> Eff effs ()
- putStopInstance :: forall t effs. Member (ContractStore t) effs => ContractInstanceId -> Eff effs ()
- deleteState :: forall t effs. Member (ContractStore t) effs => ContractInstanceId -> Eff effs ()
- data ContractDefinition t r where
- AddDefinition :: ContractDef t -> ContractDefinition t ()
- GetDefinitions :: ContractDefinition t [ContractDef t]
- addDefinition :: forall t effs. Member (ContractDefinition t) effs => ContractDef t -> Eff effs ()
- getDefinitions :: forall t effs. Member (ContractDefinition t) effs => Eff effs [ContractDef t]
Documentation
class PABContract contract where Source #
A class of contracts running in the PAB. The purpose of the type
parameter contract
is to allow for different ways of running
contracts, for example: A compiled executable running in a separate
process, or an "inline" contract that was compiled with the PAB and
runs in the same process.
The associated type families correspond to the type arguments needed
for the ContractRequest
and ContractResponse
types from
State
.
type ContractDef contract Source #
Any data needed to identify the contract. For example, the location of the executable.
Contract state type
serialisableState :: Proxy contract -> State contract -> ContractResponse Value Value PABResp PABReq Source #
Extract the serialisable state from the contract instance state.
Instances
PABContract (Builtin a) Source # | |
requests :: forall contract. PABContract contract => State contract -> [Request PABReq] Source #
The open requests of the contract instance.
data ContractEffect t r where Source #
An effect for sending updates to contracts that implement PABContract
InitialState | |
| |
UpdateContract | |
|
initialState :: forall t effs. (Member (ContractEffect t) effs, PABContract t) => ContractInstanceId -> ContractDef t -> Eff effs (State t) Source #
Get the initial state of a contract
updateContract :: forall t effs. (Member (ContractEffect t) effs, PABContract t) => ContractInstanceId -> ContractDef t -> State t -> Response PABResp -> Eff effs (State t) Source #
Send an update to the contract and return the new state.
Storing and retrieving contract state
data ContractStore t r where Source #
Storing and retrieving the state of a contract instance
PutStartInstance | |
| |
PutState | |
| |
GetState | |
| |
PutStopInstance | |
| |
GetContracts | |
| |
DeleteState | |
|
putState :: forall t effs. Member (ContractStore t) effs => ContractActivationArgs (ContractDef t) -> ContractInstanceId -> State t -> Eff effs () Source #
Store the state of the contract instance
getState :: forall t effs. Member (ContractStore t) effs => ContractInstanceId -> Eff effs (State t) Source #
Load the state of the contract instance
getDefinition :: forall t effs. Member (ContractStore t) effs => ContractInstanceId -> Eff effs (Maybe (ContractActivationArgs (ContractDef t))) Source #
Get the definition of a running contract
getActiveContracts :: forall t effs. Member (ContractStore t) effs => Eff effs (Map ContractInstanceId (ContractActivationArgs (ContractDef t))) Source #
All active contracts with their definitions WARNING : definition is misleading as this function is retrieving all instances (i.e., not only active ones), especially when the in memory database setting is used Indeed, handler defined in ContractStore ignores the status parameter given in GetContracts. Note also that a contract instance added in the db has active status set to True. This status is set to False only when the contract is explicitly stopped.
getContracts :: forall t effs. Member (ContractStore t) effs => Maybe ContractActivityStatus -> Eff effs (Map ContractInstanceId (ContractActivationArgs (ContractDef t))) Source #
All contracts with their definitions by given status (all by default)
putStartInstance :: forall t effs. Member (ContractStore t) effs => ContractActivationArgs (ContractDef t) -> ContractInstanceId -> Eff effs () Source #
putStopInstance :: forall t effs. Member (ContractStore t) effs => ContractInstanceId -> Eff effs () Source #
deleteState :: forall t effs. Member (ContractStore t) effs => ContractInstanceId -> Eff effs () Source #
Storing and retrieving definitions of contracts
data ContractDefinition t r where Source #
Storing and retrieving definitions of contracts.
(Not all t
s support this)
AddDefinition :: ContractDef t -> ContractDefinition t () | |
GetDefinitions :: ContractDefinition t [ContractDef t] |
addDefinition :: forall t effs. Member (ContractDefinition t) effs => ContractDef t -> Eff effs () Source #
getDefinitions :: forall t effs. Member (ContractDefinition t) effs => Eff effs [ContractDef t] Source #