hanami / hanami/events

Generate event ID for each adapter

Open
#69 7 comments 0 reactions 1 assignee Claimed by @davydovanton View on GitHub
enhancement
Dominant language
Ruby
Stars
41
Forks
6
PR merge metrics
No merged PRs in 30d

Description

We want to see simple way for debugging events, that's why we need to use sequences for each adapter type and generate `event_id`. For example:

```ruby
events = Hanami::Events.initialize(:memory_sync)
events.subscribe('user.created') { |payload| p payload }

events.broadcast('user.created', user_id: 1) # => event_id
```

## Backlog
- [x] Generate simple UUID as a event id (eid) (https://github.com/hanami/events/pull/80)
- [ ] Use a `meta` keyword in subscribe block for getting eid
- [ ] Try to use universally Unique Lexicographically-sortable time-based Identifiers as eid (https://github.com/abachman/ulid-ruby)

## Event type

I really love idea from redis streams:

> The ID is composed of two parts: a millisecond time and a sequence number. 1506871964177 is the millisecond time, and is just a Unix time with millisecond resolution. The number after the dot, 0, is the sequence number, and is used in order to distinguish entries added in the same millisecond. Both numbers are 64 bit unsigned integers. This means that we can add all the entries we want in a stream, even in the same millisecond.

That's why, let's create event id as `time.seq`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.