Skip to content

Commit

Permalink
WIP: hacking around issues with the rust lib
Browse files Browse the repository at this point in the history
Looks like we have to manually edit the mod.rs for models and api, also
manually delete stuff that is removed from the spec.

There's probably going to be another rev of fixes because I see a bunch
of warnings about unreachable symbols/unused.
  • Loading branch information
svix-onelson committed Feb 28, 2025
1 parent ee09966 commit fc06d28
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 24 deletions.
62 changes: 62 additions & 0 deletions rust/src/api/events_public.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
use crate::{error::Result, models::*, Configuration};

#[derive(Default)]
pub struct EventsPublicConsumerOptions {
/// Limit the number of returned items
pub limit: Option<i32>,

/// The iterator returned from a prior invocation
pub iterator: Option<String>,

/// Filters messages sent with this event type (optional).
pub event_type: Option<String>,

/// Filters messages sent with this channel (optional).
pub channel: Option<String>,

pub after: Option<String>,
}

pub struct EventsPublic<'a> {
cfg: &'a Configuration,
}

impl<'a> EventsPublic<'a> {
pub(super) fn new(cfg: &'a Configuration) -> Self {
Self { cfg }
}

/// Reads the stream of created messages for an application, filtered on the
/// Sink's event types and Channels, using server-managed iterator
/// tracking.
pub async fn consumer(
&self,
app_id: String,
sink_id: String,
consumer_id: String,
options: Option<EventsPublicConsumerOptions>,
) -> Result<PollingEndpointOut> {
let EventsPublicConsumerOptions {
limit,
iterator,
event_type,
channel,
after,
} = options.unwrap_or_default();

crate::request::Request::new(
http1::Method::GET,
"/api/v1/app/{app_id}/poller/{sink_id}/consumer/{consumer_id}",
)
.with_path_param("app_id", app_id)
.with_path_param("sink_id", sink_id)
.with_path_param("consumer_id", consumer_id)
.with_optional_query_param("limit", limit)
.with_optional_query_param("iterator", iterator)
.with_optional_query_param("event_type", event_type)
.with_optional_query_param("channel", channel)
.with_optional_query_param("after", after)
.execute(self.cfg)
.await
}
}
1 change: 1 addition & 0 deletions rust/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mod authentication;
mod background_task;
mod endpoint;
mod event_type;
mod events_public;
mod integration;
mod message;
mod message_attempt;
Expand Down
22 changes: 0 additions & 22 deletions rust/src/models/expung_all_contents_out.rs

This file was deleted.

8 changes: 6 additions & 2 deletions rust/src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub mod event_type_in;
pub mod event_type_out;
pub mod event_type_patch;
pub mod event_type_update;
pub mod expung_all_contents_out;
pub mod expunge_all_contents_out;
pub mod http_error_out;
pub mod http_validation_error;
pub mod integration_in;
Expand Down Expand Up @@ -73,6 +73,8 @@ pub mod operational_webhook_endpoint_secret_in;
pub mod operational_webhook_endpoint_secret_out;
pub mod operational_webhook_endpoint_update;
pub mod ordering;
pub mod polling_endpoint_message_out;
pub mod polling_endpoint_out;
pub mod recover_in;
pub mod recover_out;
pub mod replay_in;
Expand Down Expand Up @@ -122,7 +124,7 @@ pub use self::{
event_type_out::EventTypeOut,
event_type_patch::EventTypePatch,
event_type_update::EventTypeUpdate,
expung_all_contents_out::ExpungAllContentsOut,
expunge_all_contents_out::ExpungeAllContentsOut,
http_error_out::HttpErrorOut,
http_validation_error::HttpValidationError,
integration_in::IntegrationIn,
Expand Down Expand Up @@ -163,4 +165,6 @@ pub use self::{
status_code_class::StatusCodeClass,
template_out::TemplateOut,
validation_error::ValidationError,
polling_endpoint_message_out::PollingEndpointMessageOut,
polling_endpoint_out::PollingEndpointOut,
};

0 comments on commit fc06d28

Please sign in to comment.