pub struct PublishKafkaConfig {
pub connector: Template,
pub topic: Template,
pub key: Option<Template>,
pub value: Option<Template>,
}Expand description
Configuration for the publish_kafka integration function.
The actual Kafka producer is provided by the service layer via AsyncFunctionHandler.
Unknown keys are rejected, as for HttpCallConfig.
Fields§
§connector: TemplateNamed connector reference. A JSONLogic expression, as
HttpCallConfig::connector; read it through
Self::resolve_connector.
topic: TemplateTarget topic name, as a JSONLogic expression — so one task can route by
message content, which is the ordinary Kafka pattern:
{"cat": ["orders.", {"var": "data.region"}]}. Read it through
Self::resolve_topic.
key: Option<Template>The message key, as a JSONLogic expression. Read it through
Self::resolve_key.
Back-compat: key_logic is kept as an alias for the pre-3.9 spelling.
This field was always an expression — the rename is for consistency with
the other configs, where the _logic suffix marked the twin of a static
field that no longer exists.
value: Option<Template>The message value, as a JSONLogic expression. Read it through
Self::resolve_value.
Back-compat: value_logic is kept as an alias, as for Self::key.
Implementations§
Source§impl PublishKafkaConfig
impl PublishKafkaConfig
Sourcepub fn resolve_connector(&self, ctx: &TaskContext<'_>) -> Result<String>
pub fn resolve_connector(&self, ctx: &TaskContext<'_>) -> Result<String>
Sourcepub fn resolve_topic(&self, ctx: &TaskContext<'_>) -> Result<String>
pub fn resolve_topic(&self, ctx: &TaskContext<'_>) -> Result<String>
Sourcepub fn resolve_key(&self, ctx: &TaskContext<'_>) -> Result<Option<String>>
pub fn resolve_key(&self, ctx: &TaskContext<'_>) -> Result<Option<String>>
Resolve the message key. Ok(None) when it is not set — Kafka treats a
null key as “partition round-robin”, so a None key is the caller’s to
interpret.
Coerced to a plain string, matching HttpCallConfig::resolve_path.
§Errors
Sourcepub fn resolve_value(&self, ctx: &TaskContext<'_>) -> Result<Option<Value>>
pub fn resolve_value(&self, ctx: &TaskContext<'_>) -> Result<Option<Value>>
Resolve the message value. Ok(None) when it is not set — the fallback
(typically “serialize the whole message”) stays the caller’s policy.
Returns Option<Value>, not Option<String>, deliberately: a
producer that does serde_json::to_string unconditionally would put
different bytes on the wire for a string-valued payload than
Self::resolve_key’s plain-string coercion does. Keeping this as a
Value leaves that choice where it belongs.
§Errors
Trait Implementations§
Source§impl Clone for PublishKafkaConfig
impl Clone for PublishKafkaConfig
Source§fn clone(&self) -> PublishKafkaConfig
fn clone(&self) -> PublishKafkaConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more