resource v3.1.1
PlaceOS Resource
Abstraction over PgORM changefeeds
Implementation
PlaceOS::Resource(T)
is a layer over PgORM
models, providing an abstract interface to a table's changefeed.
abstract def process_resource(action : Action, resource : T)
process_resource(action : Action, resource : T)
is the only abstract method one must implement. On startup, the entire table is iterated asynchronously, yielding :created
events for each model.
After the initial pass, Action::Created
, Action::Deleted
, and Action::Updated
events on the table are processed as they are received.
Action::Updated
The model received with a :updated
event has the changes applied in the form of standard active-model
attribute changes information.
def on_reconnect
A non-abstract def. In its stock form, on_reconnect
is a noop.
This method can be overwritten in inheriting classes to perform actions after a changefeed is recovered.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Caspian Baska - creator and maintainer
resource
- 1
- 1
- 0
- 5
- 5
- 2 months ago
- July 17, 2020
MIT License
Fri, 27 Dec 2024 04:55:17 GMT