-(motoko async flow)
Configure this package manager Follow the instructions
A library for processing data between containers. Uses multiple attempts to send a request. Use multiple attempts to confirm the request with the result.
mops add maf
mops install
import Maf "mo:maf";
- Number of attempts by the sender: ATTEMPTS_NEW_MSG > 1
- Number of attempts by the receiver: ATTEMPTS_ACK_MSG > 1
- System time!!!: WAITING_TIME = 330_000_000_000;
- Scan interval for queue detection: PERIOD_DURATION >= 500_000_000
- Number of requests to resend: NUMBER_SHIPMENTS_ROUND > 0
- ATTEMPTS_NEW_MSG = 10;
- ATTEMPTS_ACK_MSG =10;
- WAITING_TIME = 330_000_000_000;
- NUMBER_SHIPMENTS_ROUND = 10;
- PERIOD_DURATION = #nanoseconds 5_000_000_000;
import Text "mo:base/Text";
import Maf "../lib";
actor Sender{
type MessageType = Maf.MessageType;//#NEW;#ACK;#FIN
type Config = Maf.Config;
private var CONFIG : Config = Maf.DEFAULT_CONFIG;
var lib = Maf.Sender(CONFIG);
//result from the receiver
private func HANDLER(
msg: MessageType){
switch(msg){
case(#NEW(new)){ };
case(#ACK(ack)){
//**Your any code**//
};
case(#FIN(fin)){};
};
};
//messages
public func new_message(
canister_id: Text,
payload: Blob){
await* lib.new_message(canister_id, payload);
};
public shared({caller}) func com_asyncFlow_ack(
msg: MessageType){
HANDLER(msg);
await* lib.com_asyncFlow_ack(msg, caller);
};
}
import Text "mo:base/Text";
import Maf "../lib";
actor Receiver{
type MessageType = Maf.MessageType;//#NEW;#ACK;#FIN
type Config = Maf.Config;
private var CONFIG : Config = Maf.DEFAULT_CONFIG;
private func handler(
payload: Blob): async* Blob {
//**Your any code**//
return Text.encodeUtf8("");//plug
};
var lib = Maf.Receiver(CONFIG, handler);
//messages
public shared({caller}) func com_asyncFlow_newMessage(
msg: MessageType){
await* lib.com_asyncFlow_newMessage(msg, caller);
};
public shared({caller}) func com_asyncFlow_fin(
msg: MessageType){
lib.com_asyncFlow_fin(msg);
};
}
- Version: 0.0.23 (first stable)
- Version: 0.0.24 (timer, scaner: optimization )
- Version: 0.0.25 (corrections: restart_scaner, refractoring)
- Version: 0.0.26 (async* await*)
- Version: 0.0.27 (removed unnecessary; optimization)
- Version: 0.0.28
- Version: 0.0.29 (fix)