idk
[!tldr] This explains why for the given task RESTful is better than gRPC (not relavant but good to know)
You make an excellent point. I was assuming you wanted a "Mission Control" style live map.
If your architecture is truly "Fire and Forget" (the server gives a task, and the client executes it onafhankelijk / independently), then you likely do not need gRPC.
In fact, forcing a constant verbinding (connection) for a "start-stop" system is bad engineering. It adds complexity where none is needed.
Here is the breakdown of why you should probably switch to a simpler architecture, and the one specific risk you need to cover.
1. Why "Start-Stop" kills the need for gRPC¶
In a "Start-Stop" model, the telescope is not a drone being flown by a pilot; it is a delivery driver picking up a package.
-
The Workflow:
-
Poll: Client wakes up and asks via HTTP GET: "Do you have work for me?"
-
Task: Server responds: "Yes, Image M42, 30x60s exposures."
-
Disconnect: Client goes offline (logically), slews the mount, takes images, and handles its own guiding/focusing loop.
-
Report: Client uploads the resulting FITS file via HTTP POST.
-
-
The Verdict: This is a classic RESTful state machine. You do not need streaming. You do not need binary packets. You just need a simple Todo list API.
2. The Pros of Dropping gRPC¶
If you move to a standard REST API (using standard Go net/http handlers), you solve most of the problems I warned you about:
-
No "Zombie" Connections: Since there is no persistent connection, there is no risk of the server thinking a dead client is alive.
-
Easy Debugging: You can see exactly what the client is doing by looking at the Apache/Nginx access logs (
GET /jobs/next). -
Resilience: If your server crashes and restarts while the telescope is imaging, the telescope doesn't care. It is onafhankelijk (independent). It just retries the upload later.
3. The Only Risk: The "Abort" Latency¶
There is one major downside to "Start-Stop" that you must design around: Reaction Time.
-
Scenario: You issue a 2-hour job to image a star. 10 minutes later, a Gamma Ray Burst (GRB) happens, and you want all telescopes to stop immediately and point to the new target.
-
The Problem: In a Start-Stop model, the telescope is "deaf" until it finishes its 2-hour job and checks in again. You cannot interrupt it.
-
The Solution (Without gRPC):
-
The "Heartbeat" Poll: Even while imaging, the client sends a tiny HTTP request every 30 seconds:
GET /status. -
The Response: The server usually sends
200 OK. If an emergency happens, it sends205 Reset Content, which triggers the client's "Abort" logic.
-
4. Technical Recommendation: The "Job Queue" Architecture¶
Since you are using Go, this is the cleanest way to build your backend. Do not build a "Controller"; build a Dispatcher.
The Database Schema (PostgreSQL):
JobsTable:ID,TargetRA,TargetDec,Status(Pending, Assigned, Completed),AssignedTo.
The Go Implementation (Pseudocode):
Go
// Client (The Telescope)
func main() {
for {
// 1. Ask for work
job := getNextJob() // HTTP GET
if job == nil {
time.Sleep(1 * time.Minute) // Wait if no work
continue
}
// 2. Do the work independently
// The client handles all hardware logic here
result := executeImagingRun(job)
// 3. Upload result
uploadData(result) // HTTP POST
}
}
5. Final Decision Check¶
-
Do you need to manually joystick a telescope remotely? (e.g., "Move left... a bit more...")
-
If Yes: You need gRPC/WebSockets.
-
If No: Use REST.
-
-
Do you need sub-second latency for scientific transients?
-
If Yes: You need a persistent socket (or very fast polling).
-
If No: Use REST.
-
My Advice: Stick to your "Start-Stop" idee (idea). It is much more robust for a distributed network of amateur hardware. Use standard REST (JSON over HTTP). It will save you weeks of debugging network code.
Would you like to see a Go struct for the "Job Ticket" that handles all the parameters (exposure time, filter, binning) in a single JSON object?