Skip to content

Create initial API skeleton#16

Merged
KCui0327 merged 5 commits intomainfrom
ibrahim_golang_api_server
Aug 18, 2025
Merged

Create initial API skeleton#16
KCui0327 merged 5 commits intomainfrom
ibrahim_golang_api_server

Conversation

@ibrah-m
Copy link
Collaborator

@ibrah-m ibrah-m commented Jul 6, 2025

#5

@blobcode blobcode dismissed their stale review August 3, 2025 03:05

fixed issues

@blobcode blobcode mentioned this pull request Aug 3, 2025
Copy link
Contributor

@ambroseling ambroseling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all super awesome work as the initial skeleton, I dont know how rough do we want this skeleton to be, I think if we clean this up sooner or later it would make our lives a bit easier down the road. let me know if this is reasonable or not, appreciate the work

}

func (a *App) enqueueJob(w http.ResponseWriter, r *http.Request) {
payload := map[string]interface{}{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is just skeleton but any reason why we are hardcoding the payload? we should hardcode in unit tests fs but definitely not in the actual api

return
}
w.WriteHeader(http.StatusAccepted)
fmt.Fprint(w, "enqueued")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we return a json body back to client to show the status of like did the job enqueue successfully?


func (a *App) getJobStatus(w http.ResponseWriter, r *http.Request) {
id := r.URL.Query().Get("id")
fmt.Fprintln(w, "job id=", id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this also return a http response back to client rather than printing


func (a *App) login(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
val, err := a.redisClient.Get(ctx, "some:key").Result()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we fetching some hardcoded key from redis?

}

func main() {
app := NewApp("localhost:6379", "AMD")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use env vars instead of hardcoding this?

fmt.Fprintf(w, "login page; redis says: %q\n", val)
}

func (a *App) refresh(w http.ResponseWriter, r *http.Request) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what is refresh shupposed to do?

log.Fatalf("shutdown error: %v", err)
}

log.Println("all services stopped cleanly")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for all logging we can stick to log utility for everything and not have fmt Print in some places just to keep it consistent

redisClient: client,
scheduler: scheduler,
supervisor: supervisor,
httpServer: &http.Server{Addr: ":3000", Handler: mux},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to env var

@KCui0327
Copy link
Collaborator

Overriding here since this is a template, we can address these changes in later PRs

@KCui0327 KCui0327 merged commit 32c7fba into main Aug 18, 2025
KCui0327 pushed a commit that referenced this pull request Aug 20, 2025
* Create initial API skeleton

* Add supabase-go as a dependency

* init scheduler and supervisor

* Clean up go.mod

* Fix Supervisor Start

---------

Co-authored-by: blobcode <lhelme123@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants