2024-12-27 10:51:53 +00:00
|
|
|
---
|
2024-12-29 19:59:15 +00:00
|
|
|
type: task
|
2024-12-27 10:51:53 +00:00
|
|
|
after:
|
2024-12-29 19:59:15 +00:00
|
|
|
- ./pubsub.md
|
2024-12-27 10:51:53 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
A simple mechanism should be developed which "watches" a garage directory or
|
2024-12-29 19:59:15 +00:00
|
|
|
file for changes. This mechanism has two sides.
|
2024-12-27 10:51:53 +00:00
|
|
|
|
|
|
|
## Producer
|
|
|
|
|
|
|
|
When making a change to a file in garage (putting or deleting) the producer
|
|
|
|
should publish the path to that file to a bucket-specific pubsub channel on
|
|
|
|
NATS.
|
|
|
|
|
|
|
|
This only applies for file changes which are expected to have a watcher.
|
|
|
|
|
|
|
|
## Watcher
|
|
|
|
|
|
|
|
The watcher is a simple mechanism which looks like this:
|
|
|
|
|
|
|
|
```go
|
|
|
|
type Watcher interface {
|
|
|
|
Wait(context.Context) (string, error) // returns the path to the changed file
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
It can be initialized with either a specific file path or a doublestar matcher.
|