Skip to content
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

Concretize types for client building #284

Open
glaziermag opened this issue Jul 3, 2023 · 0 comments
Open

Concretize types for client building #284

glaziermag opened this issue Jul 3, 2023 · 0 comments

Comments

@glaziermag
Copy link

glaziermag commented Jul 3, 2023

The Pulsar consumer builder is generic over DeserializeMessage but the async Pulsar client building seems to require concrete types.

let client = pulsar::Pulsar::builder("pulsar://localhost:6650", TokioExecutor)
    .build()
    .await
    .expect("Failed to create Pulsar client");

# type TestData = String;
let mut consumer: Consumer<TestData, _> = client
     .consumer()
     .with_topic("non-persistent://public/default/test")
     .with_consumer_name("test_consumer")
     .with_subscription("test_subscription")
     .build() // works with string type
     .await?;

# type TestData = unknown;  // toy generic example
  let mut consumer: Consumer<{unknown}, _> = client
     .consumer()
     .with_topic("non-persistent://public/default/test")
     .with_consumer_name("test_consumer")
     .with_subscription("test_subscription")
     .build()     // type inside `async` block must be known in this context
                       // cannot infer type for type parameter `T` declared on the method `build`
     .await?;

Should the client builder build() accept trait objects?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant