🪟External Events
Introduction
Guardian will publish a number of events to the NATS server to hook into those events, which extends the function that is suitable to the solution.
Hooks to an external event
To hook into Guardian events, we need to have a client, that is connected to the same NATS instance with Guardian and implement the response function for a specific event.
Below is the sample for .NodeJs and in the case of other languages please refer to Nats.io for complete documentation.
publish/subscribe to events
The events with type=publish
is publish/subscribe pattern so that the same message can be received by multiple clients. If there are multiple clients make sure it is handled by duplicate message processing.
To get more information please click https://github.com/nats-io/nats.js#publish-and-subscribe
request/reply events
Some event has a type=request
for which we need to subscribe and respond to the event.
Example:
For the before/after IPFS event, if the listener responds with an error then the IPFS service will be skipped and upload/respond to the actual content. This same scenario also happens when we do not have a listener to an event. For example, we can use this to encrypt/decrypt IPFS content file
External events list
Example
This example demonstrates the implementation of encryption/decryption of simple IPFS content.
Please refer to https://github.com/hashgraph/guardian/blob/main/common/src/mq/sample-external-client.ts
Last updated