immich
immich copied to clipboard
feat(server): support simple webhook
Webhook can help everybody can trigger a zapier, n8n pipline easier. We can implement some external tasks (eg: Geolocation interpolation, Face recognization) as plugins/addons by using webhook.
- [x] Remove hard-code
http://immich-machine-learning:3003/image-classifier/tag-imageandhttp://immich-machine-learning:3003/object-detection/detect-objectaway from worker service. Machine learning service is standalone now. Everyone can launch it only when necessary. - [x] Create webhook interface
POST <WEBHOOK_URL>with payload:
{
"type": "AssetCreationEvent",
"asset": {
"id": "assetId",
...
}
}
- [x] Create api
POST /webhookon ml service to received webhook request from immich server.
Is this PR for moving the rest api invoked from the server to pub/sub?
Is this PR for moving the rest api invoked from the server to pub/sub?
Only for machine learning service. Api service can communicate with machine learning service by using Redis broker. I found that machine learning service is optional. Throwing error maybe not good technically in the case of service not available.
Is this PR for moving the rest api invoked from the server to pub/sub?
Only for machine learning service. Api service can communicate with machine learning service by using Redis broker.
The communication between the server/microservices and the machine learning containers is intentionally designed to use REST apis so that people with their own custom model can make a simple web server as a drop in replacement for either object detection or image classification
The communication between the server/microservices and the machine learning containers is intentionally designed to use REST apis so that people with their own customs model can make a simple web server as a drop in replacement for either object detection or image classification
I found that machine learning service is optional. Throwing error maybe not good technically in the case of service not available. User can customs their model easily without changes as well , just need to start the machine learning service. Machine learning service listen event from broker and don't care about API or microservice service. The current implementation, you can see microservice depend on machine learning service address when create http request. For dockerless installation, users need to address their machine learning service location, someone had to modify their host file.
The communication between the server/microservices and the machine learning containers is intentionally designed to use REST apis so that people with their own custom model can make a simple web server as a drop in replacement for either object detection or image classification
If users wanna custom machine learning service in other programming language like python, R, ... I think they also use redis pub/sub easier. Of course, REST interface would be simpler, but I don't want the worker service to be dependent on other service addresses.
I prefer simplicity in this matter.
I prefer simplicity in this matter.
I have a thought about webhook. I will move to webhook approach.
What are you trying to accomplish with this PR?
My goal for the drop-in replacement is for the user spin up their web server that runs their ML model. Then from Immich's side, we make an environment variable for the current hard-coded endpoint that is now the machine learning container's DNS, and then the job should be done.
What are you trying to accomplish with this PR?
My goal for the drop-in replacement is for the user spin up their web server that runs their ML model. Then from Immich's side, we make an environment variable for the current hard-coded endpoint that is now the machine learning container's DNS, and then the job should be done.
My goals are:
- Remove dependency between worker service and machine learning service.
- Create a general-purpose method to hook asset creation/deletion/... events so that we can trigger a workflow/pipeline for other tasks (like ML job, my custom
n8nworkflow, ...)
n8n workflow can receive messages from redis pub/sub, so I think using redis pub/sub is general-purpose method. But you said that REST api is simpler with env var, then I think we can create WEBHOOK_URL var for your goals. That's all. There is no conflict with both your goals and my goals.
n8nworkflow can receive messages from redis pub/sub, so I think using redis pub/sub is general-purpose method. But you said that REST api id simpler with env var. I think we can createWEBHOOK_URLvar for your goals. That's all. There is no conflict with both your goals and my goals.
Sounds good! Let's go with the webhook approach
Is this PR still alive, or can/should it be closed?
I like this feature, and I would like to keep this PR open as a reminder of how to do it in the future