Hey Team! :wave: SST looks like a fantastic produ...
# general
e
Hey Team! 👋 SST looks like a fantastic product that solves, I’m looking at doing a Serverless-Stack course on my website https://tutorialedge.net and just wanted to ask if there are any features you think may be deprecated / any breaking changes I should be aware of coming up that I may want to watch out for when recording the videos.
t
Cool! Are you doing something Go specific?
e
Yup! I may eventually venture back into Nodejs/TypeScript but keeping my course topics quite narrow for now.
Any reference repositories featuring a more fully-fledged Go app would be very helpful!
I have to say, the live dev environment is crazy good. đź‘Ś This solves one of my biggest gripes with the likes of
sls
or even terraform
t
awesome to hear that and makes sense
I don't think we have anything super complex using Go but I don't think there's anything particular you need to watch out for
e
Very fair, I was curious to see if anyone has taken the default project structure given by sst and turned it into something more resembling a Go application’s structure.
t
no but we'd love that
My go expertise stopped like 4 years ago so I'm not sure what is the right way to do things today
ö
Damn I’ve been programming for max 2 years…
j
@elliotforbes Since we are talking about lambdas, you rarely need more than a few files (main.go, main_test.go, types.go. go.mod, go.sum). Maybe a folder for test events stored in json. But that’s about it. No need for an application project structure. These should be nanoservices
Or are you talking about using the Go bindings from the JSII translation? If so, I would advise against it.
e
I would tend to disagree here. I always tend to go for a layered approach when it comes to building any service in Go. You want your business logic to be written independently of your transport layer/storage layer logic. It makes it far easier to do things like unit testing around your more complex business logic. Having it all tightly-coupled within single files just sounds like a nightmare to me if I was developing production-ready services.
j
@elliotforbes I would tend to disagree here. When you are building a highly decoupled, event-driven system, you are likely to only need a dynamodb putitem request. That then triggers another lambda which puts it onto EventBridge, that then triggers a StepFunction which fires something into a SQS for another lambda to do something with. Etc.
It’s gotten to the point where AWS have said here’s direct SDK integration inside your StepFunctions because it’s pointless making a bunch of lambdas that just do one thing, i.e. call another AWS service
If you are building a serverless, cloud-native system you are unlikely to need more than a database write in each lambda
e
It ultimately depends on your needs. I can see myself needing some fairly complex business knowledge and validation needing to be done within the lambda itself. This shouldn’t live within a single function/module etc. I personally value splitting this out and being able to unit test use cases incredibly easily and mocking back the responses from dependencies so that I have the most possible confidence in my system.
j
Having confidence in your system doesn’t have anything to do with the amount of logic inside each lambda. I think my architecture is reliant on robust AWS services and just joining them together with event triggers.
The difficulty is not unit testing, but designing fault-tolerant systems where there are distributed transactions.
I always write full unit coverage even when it is just mocking a dynamodb operation. Because golang is hard to debug once deployed.
This is really just nanoservices as opposed to microservices. The lambda just does one or two database requests and returns the response. So it can fit in under 100 lines in main.go and then full test coverage in main_test.go with mocks and table tests against json stored events
e
Yup, if it is a nanoservice then yeah, it’s fine to keep it within the one file. I’m more trying to approach this design from the point of “I want to build a microservice which lives on lambda” The example I’ll be sort of taking is similar to how I’ve structured a previous course - https://github.com/TutorialEdge/go-rest-api-course/blob/master/internal/comment/comment.go
This does make me think I need to include something in my course which does highlight the advantages of keeping it nice and light if you are building true nanoservices like you have said.
j
You write very clean code but I’m not sure what the future of this industry holds for RESTful APIs and synchronous microservices. I find myself embracing GraphQL for external APIs and events for internal asynchronous communication. All while using off-the-shelf serverless components. Less code, predictable APIs, performant, scalable.
e
GraphQL is something I absolutely want to explore further. It just makes soo much more sense for frontends to define the exact data they need to fetch to populate views.