<commit_before># routemaster_client

A Ruby API for the [Routemaster](https://github.com/HouseTrip/routemaster) event
bus.

## Installation

Add this line to your application's Gemfile:

    gem 'routemaster_client'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install routemaster_client

## Usage

Configure your client:

```ruby
require 'routemasterclient'
client = RoutemasterClient.new(url: 'https://bus.example.com', uuid: 'john-doe')
```


Push an event about an entity in the topic `widgets` with a callback URL:

```ruby
client.created('widgets', 'https://app.example.com/widgets/1')
```

There are methods for the four canonical event types: `created`, `updated`,
`deleted`, and `noopd`.


Register to be notified about `widgets` and `kitten` at most 60 seconds after
events, in batches of at most 500 events, to a given callback URL:

```ruby
client.subscribe(
  topics:   ['widgets', 'kitten'],
  callback: 'https://app.example.com/events',
  timeout:  60_000,
  max:      500)
```


Monitor the status of topics and subscriptions:

```ruby
client.monitor_topics
#=> [ { name: 'widgets', publisher: 'john-doe', events: 12589 }, ...]

client.monitor_subscriptions
#=> [ { 
#     subscriber: 'bob',
#     callback:   'https://app.example.com/events',
#     topics:     ['widgets', 'kitten'],
#     events:     { sent: 21_450, queued: 498, oldest: 59_603 }
#  } ... ]
```

## Contributing
<commit_msg>Clarifies pushing<commit_after># routemaster_client

A Ruby API for the [Routemaster](https://github.com/HouseTrip/routemaster) event
bus.

## Installation

Add this line to your application's Gemfile:

    gem 'routemaster_client'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install routemaster_client

## Usage

Configure your client:

```ruby
require 'routemasterclient'
client = RoutemasterClient.new(url: 'https://bus.example.com', uuid: 'john-doe')
```


Push an event about an entity in the topic `widgets` with a callback URL:

```ruby
client.created('widgets', 'https://app.example.com/widgets/1')
client.updated('widgets', 'https://app.example.com/widgets/2')
client.noop('widgets', 'https://app.example.com/widgets/3')
```

There are methods for the four canonical event types: `created`, `updated`,
`deleted`, and `noop`.

`noop` is typically used when a subscriber is first connected (or reset), and
the publisher floods with `noop`s for all existing entities so subscribers can
refresh their view of the domain.

Register to be notified about `widgets` and `kitten` at most 60 seconds after
events, in batches of at most 500 events, to a given callback URL:

```ruby
client.subscribe(
  topics:   ['widgets', 'kitten'],
  callback: 'https://app.example.com/events',
  timeout:  60_000,
  max:      500)
```


Monitor the status of topics and subscriptions:

```ruby
client.monitor_topics
#=> [ { name: 'widgets', publisher: 'john-doe', events: 12589 }, ...]

client.monitor_subscriptions
#=> [ { 
#     subscriber: 'bob',
#     callback:   'https://app.example.com/events',
#     topics:     ['widgets', 'kitten'],
#     events:     { sent: 21_450, queued: 498, oldest: 59_603 }
#  } ... ]
```

## Contributing

{'fraction_non_alphanumeric': 0.14111006585136407, 'fraction_numerical': 0.020696142991533398, 'mean_word_length': 4.0474683544303796, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3886232', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1003, 'n_words': 322}