Giter VIP home page Giter VIP logo

lifeline-rs's Introduction

Hi, I'm Austin. I'm a professional Backend Engineer, with extensive Rust and Java experience. I'm the author and maintainer of tab, an intuitive, config-driven terminal multiplexer.

At work I design, build, and deploy Rust and Spring Boot services. I've also done Systems work, mostly on AWS, deploying Dockerized applications on EC2, and ALB/ECS.

In my spare time I'm a Generative Artist (see my portfolio). I use Rust and GPUs to generate intricate images for canvas prints. I use Machine Learning to solve creative problems in Pytorch.

lifeline-rs's People

Contributors

austinjones avatar mjonuschat 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

lifeline-rs's Issues

Support inspection of task state using the lifeline value

Given a lifeline value, it would be really useful if you could extract an observer which can test whether the lifeline is alive and await the termination of the lifeline task.

This would allow synchronization in shutdown code.

Swap Send/Recv order

I think it makes more sense to name based on the component, not the consumer.

CarSend: A message sent by cars.
CarRecv: A message received by cars.

Add Lifeline::leak

When a user wants to opt-out of the lifeline kill, let them leak the lifeline.

Documentation for using Resources is confusing/missing

In the documentation for Resource and Bus, it only says it "attaches a resource to the bus". However, there's no example of using a resource in Resource and the examples snippets that exist in Bus show creating the bus and then immediately trying to take a resource (which I assume would always fail). None of the example programs use Resource either as far as I can see.

After reading the documentation and examples, I had no idea of how resources got onto a Bus - it seemed like maybe they were created via the Default trait but the documentation didn't say that was required. I eventually found an example looking through your tab-rs project but having to read through a large project isn't ideal.

Unfortunately, the store_resource function is hidden away in the dyn_bus module - which I didn't even look at since it seemed like it was a low-level module that the higher level interfaces were built on. It would be helpful to at least mention the existence of store_resource in the Bus and Resource documentation.

I hope this doesn't come off as entitled. Your project looks interesting!

Add `Task::spawn_many` and `Task::try_spawn_many`

If one of the inputs to Task::spawn was &Bus, lifeline could create and execute a group of message receivers, not just one.

Lifeline would take the bus, and a FnMut spawn function which receives &Bus and returns a Future. That would pull channels off the bus using rx::()?.

spawn_many would take a core size, and a max size. If the core size could not be fulfilled, the spawn would fail.

Add a macro that merges receivers

A common pattern in tasks that maintain state is:

enum Event {
    Websocket(WebsocketRecv),
    Daemon(ConnectionRecv),
}

impl Event {
    pub fn websocket(recv: WebsocketRecv) -> Self {
        Self::Websocket(recv)
    }

    pub fn daemon(recv: ConnectionRecv) -> Self {
        Self::Daemon(recv)
    }
}

// in service spawn
let rx_websocket = bus.rx::<WebsocketRecv>()?.map(Event::websocket);
let rx_daemon = bus.rx::<ConnectionRecv>()?.map(Event::daemon);

let mut rx = rx_websocket.merge(rx_daemon);

// in task
while let Some(event) = rx.next().await {
    match event {
        // ...
    }
}

It would be nice if this was made easier by helpers or macros.

Fix cargo category slugs

the following are not valid category slugs and were ignored: Asynchronous, Rust patterns. Please see https://crates.io/category_slugs for the list of all category slugs.

Tokio, Futures, async_std, and (smol?) support via features

  • tokio-channels
  • futures-channels
  • async-std-channels
  • smol-channels ?

And for runtimes:

  • tokio-executor
  • futures-executor
  • async-std-executor
  • smol-executor

Only one executor feature is supported. Many channels are.
executor controls how tasks are spawned.

Provide a wrapper around channel implementations

Each channel implementation has slightly different error handling, async, etc.

Lifeline could provide a wrapper around them that standardizes the API. Then you could freely switch channel types. It could be generic and provide an 'into_inner()' method, in case the user wanted the underlying type.

This is particularly annoying with broadcast channels - which require a lot of handling to run correctly.

Sync support

It should be possible to write a sync API using std::sync::mpsc and blocking channels. The Storage and Channel traits should be compatible with the sync channel endpoints.

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.