-
Notifications
You must be signed in to change notification settings - Fork 11
Fluvio ingress connector #721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
04aa158
Adds fluvio connector
SirCipher 8407ac1
Tidies up documentation
SirCipher 0c3207f
Renames selectors to Relays
SirCipher 79e9f71
Integrates Relay building into Kafka connector
SirCipher 45c6af4
Adds Fluvio Form specification
SirCipher 30e72d1
Logging
SirCipher 85ff82b
Pleases clippy
SirCipher 69918b5
Fixes broken documentation link
SirCipher 2c68d6a
Merge branch 'connector-lanes' of https://github.com/swimos/swim-rust…
SirCipher 583c3b4
Updates to new connector API
SirCipher 6281c84
Merge branch 'main' of https://github.com/swimos/swim-rust into fluvio
SirCipher 0f5e443
Format
SirCipher 97ac940
Fixes broken code
SirCipher 8380f57
Refactors selector API for connectors
SirCipher 0db52c4
Restructures connector selectors
SirCipher 79e9b67
Pleases clippy
SirCipher 26c14a2
Reformat
SirCipher a45de2b
Resolves review comments
SirCipher af0dee4
Adds pubsub feature flags
SirCipher 47f7726
Pleases clippy
SirCipher d3293b1
Resolves PR comments
SirCipher 6829355
Adds missing cfg for test module
SirCipher c545c76
Merge branch 'main' of https://github.com/swimos/swim-rust into fluvio
SirCipher 328ac83
Removes old code
SirCipher c7a16d0
Fixes incorrect documentation syntax
SirCipher b56c014
Pleases rustc 1.81.0 clippy and fixes failing on machines without Flu…
SirCipher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
use crate::selector::{BadSelector, PubSubSelector, Relay, Relays}; | ||
use swimos_form::Form; | ||
|
||
/// Specification of a value lane for the connector. | ||
#[derive(Clone, Debug, Form, PartialEq, Eq)] | ||
#[form(tag = "ValueLaneSpec")] | ||
pub struct IngressValueLaneSpec { | ||
/// A name to use for the lane. If not specified, the connector will attempt to infer one from the selector. | ||
pub name: Option<String>, | ||
/// String representation of a selector to extract values for the lane from messages. | ||
pub selector: String, | ||
/// Whether the lane is required. If this is `true` and the selector returns nothing for a Message, the | ||
/// connector will fail with an error. | ||
pub required: bool, | ||
} | ||
|
||
impl IngressValueLaneSpec { | ||
/// # Arguments | ||
/// * `name` - A name to use for the lane. If not specified the connector will attempt to infer a name from the selector. | ||
/// * `selector` - String representation of the selector to extract values from the message. | ||
/// * `required` - Whether the lane is required. If this is `true` and the selector returns nothing for a Message, the | ||
/// connector will fail with an error. | ||
pub fn new<S: Into<String>>(name: Option<S>, selector: S, required: bool) -> Self { | ||
IngressValueLaneSpec { | ||
name: name.map(Into::into), | ||
selector: selector.into(), | ||
required, | ||
} | ||
} | ||
} | ||
|
||
/// Specification of a value lane for the connector. | ||
#[derive(Clone, Debug, Form, PartialEq, Eq)] | ||
#[form(tag = "MapLaneSpec")] | ||
pub struct IngressMapLaneSpec { | ||
/// The name of the lane. | ||
pub name: String, | ||
/// String representation of a selector to extract the map keys from the messages. | ||
pub key_selector: String, | ||
/// String representation of a selector to extract the map values from the messages. | ||
pub value_selector: String, | ||
/// Whether to remove an entry from the map if the value selector does not return a value. Otherwise, missing | ||
/// values will be treated as a failed extraction from the message. | ||
pub remove_when_no_value: bool, | ||
/// Whether the lane is required. If this is `true` and the selector returns nothing for a Message, the | ||
/// connector will fail with an error. | ||
pub required: bool, | ||
} | ||
|
||
impl IngressMapLaneSpec { | ||
/// # Arguments | ||
/// * `name` - The name of the lane. | ||
/// * `key_selector` - String representation of a selector to extract the map keys from the messages. | ||
/// * `value_selector` - String representation of a selector to extract the map values from the messages. | ||
/// * `remove_when_no_value` - Whether to remove an entry from the map if the value selector does not return a value. Otherwise, missing | ||
/// values will be treated as a failed extraction from the message. | ||
/// * `required` - Whether the lane is required. If this is `true` and the selector returns nothing for a Message, the | ||
/// connector will fail with an error. | ||
pub fn new<S: Into<String>>( | ||
name: S, | ||
key_selector: S, | ||
value_selector: S, | ||
remove_when_no_value: bool, | ||
required: bool, | ||
) -> Self { | ||
IngressMapLaneSpec { | ||
name: name.into(), | ||
key_selector: key_selector.into(), | ||
value_selector: value_selector.into(), | ||
remove_when_no_value, | ||
required, | ||
} | ||
} | ||
} | ||
|
||
/// Specification of a value relay for the connector. | ||
#[cfg(feature = "pubsub")] | ||
#[derive(Clone, Debug, Form, PartialEq, Eq)] | ||
#[form(tag = "ValueRelaySpec")] | ||
pub struct PubSubValueRelaySpecification { | ||
/// A node URI selector. See [`crate::selector::NodeSelector`] for more information. | ||
pub node: String, | ||
/// A lane URI selector. See [`crate::selector::LaneSelector`] for more information. | ||
pub lane: String, | ||
/// A payload URI selector. See [`crate::selector::RelayPayloadSelector::value`] for more information. | ||
pub payload: String, | ||
/// Whether the payload selector must yield a value. If it does not, then the selector will | ||
/// yield an error. | ||
pub required: bool, | ||
} | ||
|
||
/// Specification of a map relay for the connector. | ||
#[cfg(feature = "pubsub")] | ||
#[derive(Clone, Debug, Form, PartialEq, Eq)] | ||
#[form(tag = "MapRelaySpec")] | ||
pub struct PubSubMapRelaySpecification { | ||
/// A node URI selector. See [`crate::selector::NodeSelector`] for more information. | ||
pub node: String, | ||
/// A lane URI selector. See [`crate::selector::LaneSelector`] for more information. | ||
pub lane: String, | ||
/// A payload URI selector. See [`crate::selector::RelayPayloadSelector::map`] for more information. | ||
pub key: String, | ||
/// A payload URI selector. See [`crate::selector::RelayPayloadSelector::map`] for more information. | ||
pub value: String, | ||
/// Whether the payload selector must yield a value. If it does not, then the selector will | ||
/// yield an error. | ||
pub required: bool, | ||
/// If the value selector fails to select, then it will emit a map remove command to remove the | ||
/// corresponding entry. | ||
pub remove_when_no_value: bool, | ||
} | ||
|
||
/// Specification of a relay for the connector. | ||
#[cfg(feature = "pubsub")] | ||
#[derive(Clone, Debug, Form, PartialEq, Eq)] | ||
pub enum PubSubRelaySpecification { | ||
/// Specification of a value relay for the connector. | ||
Value(PubSubValueRelaySpecification), | ||
/// Specification of a map relay for the connector. | ||
Map(PubSubMapRelaySpecification), | ||
} | ||
|
||
#[cfg(feature = "pubsub")] | ||
impl TryFrom<Vec<PubSubRelaySpecification>> for Relays<PubSubSelector> { | ||
type Error = BadSelector; | ||
|
||
fn try_from(value: Vec<PubSubRelaySpecification>) -> Result<Self, Self::Error> { | ||
use crate::selector::{ | ||
parse_lane_selector, parse_map_selector, parse_node_selector, parse_value_selector, | ||
}; | ||
|
||
let mut chain = Vec::with_capacity(value.len()); | ||
|
||
for spec in value { | ||
match spec { | ||
PubSubRelaySpecification::Value(PubSubValueRelaySpecification { | ||
node, | ||
lane, | ||
payload, | ||
required, | ||
}) => { | ||
let relay = Relay::new( | ||
parse_node_selector(node.as_str())?, | ||
parse_lane_selector(lane.as_str())?, | ||
parse_value_selector(payload.as_str(), required)?, | ||
); | ||
chain.push(relay); | ||
} | ||
PubSubRelaySpecification::Map(PubSubMapRelaySpecification { | ||
node, | ||
lane, | ||
key, | ||
value, | ||
required, | ||
remove_when_no_value, | ||
}) => { | ||
let relay = Relay::new( | ||
parse_node_selector(node.as_str())?, | ||
parse_lane_selector(lane.as_str())?, | ||
parse_map_selector( | ||
key.as_str(), | ||
value.as_str(), | ||
required, | ||
remove_when_no_value, | ||
)?, | ||
); | ||
chain.push(relay); | ||
} | ||
} | ||
} | ||
|
||
Ok(Relays::new(chain)) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pub mod format; | ||
mod ingress; | ||
|
||
pub use ingress::*; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.