Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

LaravelSimpleAsyncDataStreamer

a simple async message/data streamer, that you can include it anywhere in your app and stream the data as soon as its recived from another end while being 100% decoupled.

its kinda similar to context but much simpler and without the auto logging of data, you can use it to easily group all your process messages into one place instead of using a scatterd loggers everywhere or passing dependencies to deeply nested logic.

usage examples :

  • a console command with nested steps
  • a multi step pipeline
  • etc...

Usage

  • first bind the class to the ioc in AppServiceProvider
use App\SimpleDataStreamer;

public function register(): void
{
    $this->app->scoped(SimpleDataStreamer::class, static fn (): SimpleDataStreamer => new SimpleDataStreamer());
}
  • listen to emitted messages and stream them
    • the stream is async which means it doesnt block whatever comes after it.
SimpleDataStreamer::stream(function (string $msg, array $data): void {
    // do whatever you want
});
  • next anywhere you want to emit a message
SimpleDataStreamer::step('data process');
// or
SimpleDataStreamer::append('processing done', [
    'some' => 'data'
]);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages