This is my first post here and I hope I have the right section for this type of question.
I’ve been developing a platform using Node.js for some time now, which consists of two GraphQL gateways and a dozen different microservices. The architecture is quite simple, a request hits a gateway and GraphQL routes the request to the right services, which does some work like creating data, and then the service sends the result back to the gateway, which gets returned to the client.
I’ve decided to convert the microservices from Node.js to Go because I simply can’t stand working in Node.js/JS any longer. I dread having to write anymore JS/Node.js on the backend and since I started working with Go a couple weeks ago, I’ve fallen in love and am excited to develop again. Carrying on with Node would be like carrying on in a unhealthy, dysfunctional relationship, with zero trust and daily insanity/abuse lol.
In the current platform, each microservice has access to a standard library that has approximately 24 functions for doing stuff like creating, getting, deleting, and validating data. It’s designed around polyglot persistence and we use Neo4j, MongoDB, PostgreSQL and Redis.
Each function in the main library such as create, is broken down into smaller functions (components), which are composed using custom pipe function, which takes an array of the create components, executes each component and builds an “immutable” request state object with the result of each functions execution. Some functions need the result of a previous function and get that from the state object. If something fails, a handler takes the request state and ensures the databases are rolled back correctly.
I was hoping to use a similar style and write a Go library that all Go services could utilize but I do not know if this architecture would be consider a good practice in Go? I’m still relatively new to the language. I’d have functions for create, get, soft delete, hard delete, list, update, etc. and then functions for each step. Currently, each step (function/component) has it’s own file in a parent directory such as create.
I was hoping to avoid composing functions in the style of a(b(c(d()))) in favor of iterating of a slice of functions.
Maybe this way of thinking is wrong in Go and there is a better way?
Anyways, I was hoping for some suggestions how to translate what I’ve currently built over to Go.