Skip to content

Libs: replace beta "events public" with the new "message poller" #1893

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
merged 2 commits into from
Apr 17, 2025
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
17 changes: 17 additions & 0 deletions bridge/svix-bridge.example.receivers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ opentelemetry:
# Inputs types are "webhook" which allows you to configure a verification scheme
# (either "svix" or "none") or "svix-webhook" which is a shorthand version.
#
# There is also a "svix-message-poller" input type which will poll a polling endpoint
# rather than waiting for incoming messages.
#
# ```
# input:
# type: "webhook"
Expand Down Expand Up @@ -125,3 +128,17 @@ receivers:
# Only for SASL
kafka_sasl_username: "user"
kafka_sasl_password: "pass"

- name: "msg-poller-to-rabbitmq-example"
input:
type: "svix-message-poller"
consumer_id: "example-consumer"
# The app and sink ids can be seen in the URL for the corresponding Polling Endpoint.
app_id: "my-app-uid"
sink_id: "poll_XXXX"
token: "${POLLING_ENDPOINT_TOKEN}"
output:
type: "rabbitmq"
uri: "${QUEUE_URI}"
exchange: ""
routing_key: "my_queue"
4 changes: 2 additions & 2 deletions bridge/svix-bridge/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl WebhookReceiverConfig {
#[derive(Clone, Deserialize)]
#[serde(tag = "type", rename_all = "kebab-case")]
pub enum PollerInputOpts {
SvixPollingEndpoint {
SvixMessagePoller {
/// Identifies this client, allowing the server to track progress during iteration.
/// Processes should not share a consumer id. Only exclusive access is permitted.
consumer_id: String,
Expand All @@ -260,7 +260,7 @@ pub enum PollerInputOpts {
impl PollerInputOpts {
pub fn svix_client(&self) -> Option<Svix> {
match self {
PollerInputOpts::SvixPollingEndpoint {
PollerInputOpts::SvixMessagePoller {
token,
svix_options,
..
Expand Down
2 changes: 1 addition & 1 deletion bridge/svix-bridge/src/config/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ fn test_pollers_parse_ok() {
receivers:
- name: "poller-to-rabbitmq-example"
input:
type: "svix-polling-endpoint"
type: "svix-message-poller"
consumer_id: "my-consumer"
app_id: "app_AbCd"
sink_id: "poll_aBcD"
Expand Down
15 changes: 7 additions & 8 deletions bridge/svix-bridge/src/webhook_receiver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use axum::{
use svix_bridge_types::{
async_trait,
svix::{
api::{EventsPublicConsumerOptions, Svix},
api::{MessagePollerConsumerPollOptions, Svix},
error::Error,
},
ForwardRequest, PollerInput, ReceiverOutput, TransformationConfig, TransformerInput,
Expand Down Expand Up @@ -258,7 +258,7 @@ async fn run_inner(poller: &SvixEventsPoller) -> ! {
const NO_SLEEP: Duration = Duration::ZERO;
let mut sleep_time = NO_SLEEP;

let PollerInputOpts::SvixPollingEndpoint {
let PollerInputOpts::SvixMessagePoller {
consumer_id,
token: _,
app_id,
Expand All @@ -269,19 +269,18 @@ async fn run_inner(poller: &SvixEventsPoller) -> ! {
let mut iterator = None;

'outer: loop {
tracing::trace!(app_id, sink_id, "polling endpoint");
tracing::trace!(app_id, sink_id, "polling poller");
match poller
.svix_client
.events_public()
.consumer(
.message()
.poller()
.consumer_poll(
app_id.clone(),
sink_id.clone(),
consumer_id.clone(),
Some(EventsPublicConsumerOptions {
Some(MessagePollerConsumerPollOptions {
limit: None,
iterator: iterator.clone(),
event_type: None,
channel: None,
}),
)
.await
Expand Down
198 changes: 0 additions & 198 deletions csharp/Svix/EventsPublic.cs

This file was deleted.

10 changes: 1 addition & 9 deletions csharp/Svix/MessagePoller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,11 @@ public class MessagePollerConsumerPollOptions : SvixOptionsBase
{
public ulong? Limit { get; set; }
public string? Iterator { get; set; }
public string? EventType { get; set; }
public string? Channel { get; set; }

public new Dictionary<string, string> QueryParams()
{
return SerializeParams(
new Dictionary<string, object?>
{
{ "limit", Limit },
{ "iterator", Iterator },
{ "event_type", EventType },
{ "channel", Channel },
}
new Dictionary<string, object?> { { "limit", Limit }, { "iterator", Iterator } }
);
}
}
Expand Down
6 changes: 0 additions & 6 deletions go/message_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ type MessagePollerConsumerPollOptions struct {
Limit *uint64
// The iterator returned from a prior invocation
Iterator *string
// Filters messages sent with this event type (optional).
EventType *string
// Filters messages sent with this channel (optional).
Channel *string
}

type MessagePollerConsumerSeekOptions struct {
Expand Down Expand Up @@ -100,8 +96,6 @@ func (messagePoller *MessagePoller) ConsumerPoll(
if o != nil {
internal.SerializeParamToMap("limit", o.Limit, queryMap, &err)
internal.SerializeParamToMap("iterator", o.Iterator, queryMap, &err)
internal.SerializeParamToMap("event_type", o.EventType, queryMap, &err)
internal.SerializeParamToMap("channel", o.Channel, queryMap, &err)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion go/models/api_token_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "time"
type ApiTokenOut struct {
CreatedAt time.Time `json:"createdAt"`
ExpiresAt *time.Time `json:"expiresAt,omitempty"`
Id string `json:"id"` // The ApplicationToken's ID.
Id string `json:"id"` // The GlobalApplicationToken's ID.
Name *string `json:"name,omitempty"`
Scopes []string `json:"scopes,omitempty"`
Token string `json:"token"`
Expand Down
Loading