Coder Social home page Coder Social logo

cloud-pubsub's People

Contributors

ant32 avatar bigjerbd avatar bruceg avatar endor avatar hseeberger avatar kayleg avatar novedevo avatar olofwalker avatar ruseinov avatar sync avatar tehanswer avatar yury avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cloud-pubsub's Issues

`Error` type is not usable as as a standard error type

To be usable as a standard error type, this type needs to implement std::error::Error, which implies both std::fmt::Debug and std::fmt::Display. Error can be trivially implemented, and Debug can be auto-derived, so this means providing a Display method.

Auto-refresh auth tokens.

It might actually be beneficial to auto-refresh tokens by checking if they are close to expiration as having to spawn a separate thread for that seems laborious.

The current approach I've taken is as follows:

pub fn init_pubsub() -> cloud_pubsub::Client {
    ....

    let client = cloud_pubsub::Client::new_with_string(pubsub_credentials).unwrap();
    let refresh_client = client.clone();
    spawn(lazy(move |_ctx| {
        refresh_client.spawn_token_renew(GOOGLE_TOKEN_REFRESH_INTERVAL)
    }));
    client
}

But I can't imagine a scenario where one would not want to refresh token when it expires, nor do I think it's an implementation detail that the library user should care about.

What we could do is check token expiration on request and if it's close to be expired - spawn renew it right there and then.
It just has to be implemented in a performant way.

I do understand why the current approach has been taken: it makes the library easier to read and understand, but I'm sure we can come up with a solution that would work just as well without the extra burden on the user's side.

Support attributes in EncodedMessage

by looking at the payload i've noticed that we only publish the data to Pub/sub

#[derive(Deserialize, Clone, Serialize)]
pub struct EncodedMessage {
    data: String,
}

There's a really useful field named attributes that would be really nice to have. It helps filtering message within a subscription
(see https://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage)

I'll make a PR of the forked version that I'm using that has this feature, maybe we can integrate it properly :)

Thanks!

How to relate ack_ids and messages in subscription::get_messages result?

In subscription::get_messages the ack_ids are decoupled from the converted messages, since the function returns two vectors.

        let messages = response.received_messages.unwrap_or_default();
        let ack_ids: Vec<String> = messages
            .as_slice()
            .iter()
            .map(|packet| packet.ack_id.clone())
            .collect();
        let packets = messages
            .into_iter()
            .filter_map(|packet| match T::from(packet.message) {
                Ok(o) => Some(o),
                Err(e) => {
                    error!("Failed converting pubsub {}", e,);
                    None
                }
            })
            .collect();

        Ok((packets, ack_ids))

If messages cannot be converted, they are dropped. So how would I know which ack_id is for which message? On the happy path the are correlated by index, but if some messages are dropped, that is no longer the case.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.