1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! Distributed workflow execution types (requires `distributed` feature).
//!
//! This module defines the [`PeerClient`] trait and the lightweight
//! request/response types that [`Workflow::run_remote`] uses to invoke a
//! workflow on a remote node. The types are transport-agnostic —
//! `blazen-peer` provides the canonical gRPC implementation of
//! [`PeerClient`] via `BlazenPeerClient`, but any transport (HTTP, NATS,
//! in-process mock, etc.) can implement the trait.
//!
//! ## Why a trait instead of a concrete client?
//!
//! `blazen-peer` depends on `blazen-core` (it needs [`crate::Context`],
//! [`crate::StepRegistration`], etc.). If `blazen-core` depended back on
//! `blazen-peer` there would be a cyclic crate dependency. Defining the
//! trait here lets `blazen-core` stay at the bottom of the dependency
//! graph while `blazen-peer` implements the trait from above.
use HashMap;
use Future;
use Pin;
use Uuid;
use crateWorkflowError;
use crateRemoteRefDescriptor;
// ---------------------------------------------------------------------------
// Request / Response
// ---------------------------------------------------------------------------
/// Transport-agnostic request for invoking a sub-workflow on a remote
/// peer.
///
/// Mirrors the fields of `blazen_peer::protocol::SubWorkflowRequest`
/// but without the postcard/serde wire encoding — the [`PeerClient`]
/// implementor is responsible for serializing this into whatever format
/// the transport requires.
/// Transport-agnostic response from a remote sub-workflow invocation.
///
/// Mirrors the useful parts of
/// `blazen_peer::protocol::SubWorkflowResponse` in a form that
/// [`Workflow::run_remote`] can consume without depending on
/// `blazen-peer`.
// ---------------------------------------------------------------------------
// Trait
// ---------------------------------------------------------------------------
/// Abstraction over a transport that can invoke a sub-workflow on a
/// remote node.
///
/// The canonical implementation lives in `blazen-peer` as
/// `BlazenPeerClient`. Tests can supply a mock implementation that
/// returns canned responses without standing up a gRPC server.