Add and test TryMakeFetcher, TryMakeSender, and NodeHasTag helpers
Using a Fetcher for a channel on nodes where it exists and triggering
logic to handle other nodes based on whether the fetcher is valid works
well for some use cases. Add a method to EventLoop to support that
directly, instead of forcing the caller to redo the logic around whether
a channel exists and is readable. Basing similar logic off whether the
node has a given tag is also fairly common.
In the process, fill out the EventLoop tests around channels that don't
exist or aren't readable/writable a bit better.
Change-Id: I168e3c1e98adc4461a01d98360f0f0a78d24bbb5
Signed-off-by: Brian Silverman <brian.silverman@bluerivertech.com>
diff --git a/aos/configuration.h b/aos/configuration.h
index e8722d6..9cb1132 100644
--- a/aos/configuration.h
+++ b/aos/configuration.h
@@ -113,6 +113,10 @@
std::vector<const Node *> GetNodesWithTag(const Configuration *config,
std::string_view tag);
+// Returns whether the given node has the provided tag. If this is a single-node
+// world, we assume that all tags match.
+bool NodeHasTag(const Node *node, std::string_view tag);
+
// Returns the node index for a node. Note: will be faster if node is a pointer
// to a node in config, but is not required.
int GetNodeIndex(const Configuration *config, const Node *node);