module arch.node.engines.shard_messages;

import prelude open;
import arch.node.types.basics open;
import arch.node.types.identities open;

type KVSReadRequestMsg :=
  mkKVSReadRequestMsg@{
    timestamp : TxFingerprint;
    key : KVSKey;
    actual : Bool;
  };

type KVSWriteMsg :=
  mkKVSWriteMsg@{
    timestamp : TxFingerprint;
    key : KVSKey;
    datum : Option KVSDatum;
  };

type UpdateSeenAllMsg :=
  mkUpdateSeenAllMsg@{
    timestamp : TxFingerprint;
    write : Bool;
  };

type KVSAcquireLockMsg :=
  mkKVSAcquireLockMsg@{
    lazy_read_keys : Set KVSKey;
    eager_read_keys : Set KVSKey;
    will_write_keys : Set KVSKey;
    may_write_keys : Set KVSKey;
    worker : EngineID;
    executor : EngineID;
    timestamp : TxFingerprint;
  };

type KVSLockAcquiredMsg :=
  mkKVSLockAcquiredMsg@{
    timestamp : TxFingerprint;
  };

type KVSReadMsg :=
  mkKVSReadMsg@{
    timestamp : TxFingerprint;
    key : KVSKey;
    data : KVSDatum;
  };

type ShardMsg :=
  | KVSReadRequest KVSReadRequestMsg
  | KVSWrite KVSWriteMsg
  | KVSAcquireLock KVSAcquireLockMsg
  | KVSLockAcquired KVSLockAcquiredMsg
  | KVSRead KVSReadMsg
  | UpdateSeenAll UpdateSeenAllMsg;