Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl Client {
/// # .source("https://www.eventsourcingdb.io".to_string())
/// # .data(json!({"value": 1}))
/// # .subject("/test".to_string())
/// # .r#type("io.eventsourcingdb.test".to_string())
/// # .ty("io.eventsourcingdb.test".to_string())
/// # .build()
/// # ],
/// # vec![]
Expand Down Expand Up @@ -419,7 +419,7 @@ impl Client {
/// .source("https://www.eventsourcingdb.io".to_string())
/// .data(json!({"value": 1}))
/// .subject("/test".to_string())
/// .r#type("io.eventsourcingdb.test".to_string())
/// .ty("io.eventsourcingdb.test".to_string())
/// .build()
/// ];
/// let written_events = client.write_events(candidates, vec![]).await.expect("Failed to write events");
Expand Down
1 change: 1 addition & 0 deletions src/client/request_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub enum BoundType {
#[serde(rename_all = "camelCase")]
pub struct Bound<'a> {
/// The type of the bound
#[serde(rename = "type")]
pub bound_type: BoundType,
/// The value of the bound
pub id: &'a str,
Expand Down
9 changes: 5 additions & 4 deletions src/event/event_types/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ pub struct Event {
time: DateTime<Utc>,
#[serde(flatten)]
traceinfo: Option<TraceInfo>,
r#type: String,
#[serde(rename = "type")]
ty: String,
}

impl Event {
Expand Down Expand Up @@ -89,7 +90,7 @@ impl Event {
/// Get the type of an event.
#[must_use]
pub fn ty(&self) -> &str {
&self.r#type
&self.ty
}
}

Expand All @@ -99,7 +100,7 @@ impl From<Event> for EventCandidate {
data: event.data,
source: event.source,
subject: event.subject,
r#type: event.r#type,
ty: event.ty,
traceinfo: event.traceinfo,
}
}
Expand All @@ -111,7 +112,7 @@ impl From<Event> for cloudevents::Event {
let mut builder = cloudevents::EventBuilderV10::new()
.source(event.source)
.subject(event.subject)
.ty(event.r#type)
.ty(event.ty)
.id(event.id)
.time(event.time.to_string())
.data(event.datacontenttype, event.data);
Expand Down
5 changes: 3 additions & 2 deletions src/event/event_types/event_candidate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ pub struct EventCandidate {
/// The type of the event.
/// This has to be a reverse domain name.
#[builder(setter(into))]
pub r#type: String,
#[serde(rename = "type")]
pub ty: String,
/// The traceparent of the event.
/// This is used for distributed tracing.
#[builder(default, setter(strip_option))]
Expand All @@ -52,7 +53,7 @@ impl TryFrom<cloudevents::Event> for EventCandidate {
data,
source: event.source().to_string(),
subject,
r#type: event.ty().to_string(),
ty: event.ty().to_string(),
traceinfo,
})
}
Expand Down
7 changes: 4 additions & 3 deletions src/event/event_types/management_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ pub struct ManagementEvent {
specversion: String,
subject: String,
time: DateTime<Utc>,
r#type: String,
#[serde(rename = "type")]
ty: String,
}

impl ManagementEvent {
Expand Down Expand Up @@ -68,7 +69,7 @@ impl ManagementEvent {
/// This method is called `ty` to avoid conflicts with the `type` keyword in Rust.
#[must_use]
pub fn ty(&self) -> &str {
&self.r#type
&self.ty
}
}

Expand All @@ -79,7 +80,7 @@ impl From<ManagementEvent> for cloudevents::Event {
cloudevents::EventBuilderV10::new()
.source(event.source)
.subject(event.subject)
.ty(event.r#type)
.ty(event.ty)
.id(event.id)
.time(event.time.to_string())
.data(event.datacontenttype, event.data)
Expand Down
4 changes: 2 additions & 2 deletions tests/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn create_test_eventcandidate(
.source("https://www.eventsourcingdb.io".to_string())
.data(data.into())
.subject(subject.to_string())
.r#type("io.eventsourcingdb.test".to_string())
.ty("io.eventsourcingdb.test".to_string())
.build()
}

Expand All @@ -34,7 +34,7 @@ pub fn assert_event_match_eventcandidate(
&event_candidate.subject,
"Subject mismatch"
);
assert_eq!(event.ty(), &event_candidate.r#type, "Type mismatch");
assert_eq!(event.ty(), &event_candidate.ty, "Type mismatch");
assert_eq!(
event.traceinfo(),
event_candidate.traceinfo.as_ref(),
Expand Down
4 changes: 2 additions & 2 deletions tests/write_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ async fn write_single_event_with_traceparent() {
.source("https://www.eventsourcingdb.io".to_string())
.data(json!({"value": 1}))
.subject("/test".to_string())
.r#type("io.eventsourcingdb.test".to_string())
.ty("io.eventsourcingdb.test".to_string())
.traceinfo(TraceInfo::Traceparent {
traceparent: "00-01234567012345670123456701234567-0123456701234567-00".to_string(),
})
Expand All @@ -302,7 +302,7 @@ async fn write_single_event_with_traceparent_and_state() {
.source("https://www.eventsourcingdb.io".to_string())
.data(json!({"value": 1}))
.subject("/test".to_string())
.r#type("io.eventsourcingdb.test".to_string())
.ty("io.eventsourcingdb.test".to_string())
.traceinfo(TraceInfo::WithState {
traceparent: "00-01234567012345670123456701234567-0123456701234567-00".to_string(),
tracestate: "state=12345".to_string(),
Expand Down