samvcodes
samvcodes
  • 28
  • 188 728
gRPC Microservice Structure in Go! (DDD and Hexagonal Architecture Example)
Open source Github repo: github.com/samverrall/microservice-example
In this video, I show an opinionated example of how you may structure a gRPC microservice in Golang. I discuss the advantages such from hexagonal architecture such as application layers, read and write repositories and the benefits of keeping your application logic outside of your transport layers.
The video does not showcase production-ready code but should give you a good idea of an approach you could take when implementing a microservice in Golang.
I took a lot of inspiration from the following repository github.com/polyscone/tofu from @polyscone when implementing this example microservice - check the repository!
Twitter: samvcodes
Github: github.com/samverrall
Переглядів: 4 016

Відео

A REAL Benefit of DDD in Go! ~ Domain Driven Design in Golang Example
Переглядів 6 тис.8 місяців тому
To try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/samvcodes or click on the link in the description. The first 200 of you will get 20% off Brilliant's annual premium subscription. DISCORD: discord.gg/FT3JYcDRrx In this video, I compiled an example use case Domain Driven Design structure in Golang. The video aims to showcase one of the real benefits of using D...
Raw SQL Queries in Go LIKE a 10x Engineer! - Repository Pattern Example
Переглядів 6 тис.9 місяців тому
I'm sure as a Go engineer you've had to work with raw SQL queries in Go before! Maintaining raw SQL queries can be a pain. So in this video, I discuss a pattern I've been following recently to help manage SQL queries within my repository implementations. It's a simple concept but nonetheless, I thought it was worth a video as I've seen some pretty unmaintable code dealing with this in the past....
Setup HTMX + HTML Templates in Golang!? HTMX with Fiber
Переглядів 5 тис.9 місяців тому
DISCORD: discord.gg/3VFCHFVrMQ I had a few questions regarding setting up HTMX Templates with Fiber, so the aim of this video is to give you an idea (one of many approaches) you can take to set up an HTMX Project with Golang, parse HTML Go templates and start building Web Applications with HTMX in Golang. I cover the initial template files you will require, importing HTMX, how I return partial ...
Structured logging in Go with Slog! Golang LOGGING like a 10x ENGINEER
Переглядів 6 тис.9 місяців тому
In this video, I discuss structured logging in Golang with the new standard library package slog. I dive into how you can set up your logger with Slog Handlers, contextual logging with request IDs, setting up log levels in Go via flags or environment variables and some general best practices of logging in GO. The aim of this video is to give you an idea of how you can set up logging in Go, and ...
Event Driven Modular Monolith in Go!? | Designing my Backend Architecture [HTMX and Go]
Переглядів 5 тис.9 місяців тому
To try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/samvcodes or click on the link in the description. The first 200 of you will get 20% off Brilliant's annual premium subscription . In this video, I discuss my initial system design for a start-up I'm building using Go, HTMX and some other fun stuff. I discuss the benefits of building a decoupled modular monoli...
Golang + HTMX Project Structure | How I’ve Structured My HTMX Go App
Переглядів 8 тис.9 місяців тому
DISCORD SERVER: discord.gg/uMKKg79cP3 In this video, I review the structure of a Golang HTMX web application. I discuss how I've set up my HTML template files to best use HTMX and the Go templating engine. I cover how you can set up routes for HTMX so that you only render partials within specific routes. On top of templating, I also cover the use of Hexagonal Architecture, so that your core bus...
Postgres Integration tests in Golang?! ~ Integration Testing in Go
Переглядів 3,7 тис.10 місяців тому
In this video, I review a nice way of testing your repositories in Golang using in-memory Postgres implementation. I also show an example of how you can write tests for your repositories in a way which enables you to reuse the same tests - without writing new test cases for a new implementation. I.e the same set of tests can be used by different implementations. Integration tests for your SQL q...
Dynamic Feature Flags with Go Routines!? ~ Feature Switches in Golang
Переглядів 1,4 тис.10 місяців тому
To try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/samvcodes or click on the link in the description. The first 200 of you will get 20% off Brilliant's annual premium subscription. In this video, I show a practical example of a dynamic feature switch system in Golang utilising Go routines. The concept is pretty simple, a Go routine is spun up to watch the feat...
Business Logic Layers in your Golang services!? - Golang Service Architecture
Переглядів 3,1 тис.10 місяців тому
In this video, I go through a simplistic Service Pattern approach that you can use in your Golang services to isolate your business logic within its own Business Layer. This concept is essentially a dulled-down version of Clean Architecture in Go and Hexagonal Architecture in Go, to keep your business rules isolated away from data layers and "adapters" such as HTTP API's. I essentially wanted t...
Components with HTML Templates in Go!? ~ FULL STACK Golang
Переглядів 8 тис.11 місяців тому
Discord: discord.gg/qvKwRegRFP In this video, I talk about "component" like HTML template files in Golang, which may remind you of React and Vue components for example. These components leverage the standard template/html package in Golang, and make your life a lot easier when building WebU UI's in your Golang Full Stack applications. Let me know what you think of the concept! I've personally f...
The Options Pattern in Golang!? ~ Service Configuration
Переглядів 1,8 тис.11 місяців тому
MY DISCORD!: discord.gg/TsbMDmejF5 In this video, I discuss a simple concept to set optional fields with Golang structs/library configuration, this is commonly known as the Options pattern. I typically use this pattern for setting optional fields on things like HTTP servers (as shown in this video), and any library with defaults that can be overwritten etc I personally prefer this approach rath...
THIS is how you SHOULD Structure your Golang Applications!?
Переглядів 6 тис.11 місяців тому
MY DISCORD SERVER: discord.gg/AQgPCq6Jx9 In this video, I talk about software design/software architecture patterns in Golang. I dive into whether you should even bother with architecture patterns for your services, and the importance of picking when it is right to use something like Hexagonal architecture, Clean architecture or Domain Driven Design. I also talk about just structuring side proj...
Object Value Types in Go!? ~ Domain Driven Design
Переглядів 1,6 тис.11 місяців тому
Object Value Types in Go!? ~ Domain Driven Design
Implementing IP Address Rate Limiting in Go!?
Переглядів 1,7 тис.11 місяців тому
Implementing IP Address Rate Limiting in Go!?
Golang Request Validation ERROR HANDLING like a 10x ENGINEER!?
Переглядів 4,9 тис.Рік тому
Golang Request Validation ERROR HANDLING like a 10x ENGINEER!?
Backgrounds Jobs with Go Routines! - Golang Concurrency Example
Переглядів 3,2 тис.Рік тому
Backgrounds Jobs with Go Routines! - Golang Concurrency Example
A REAL usecase of Golang Go Routines! - Golang Concurrency Example
Переглядів 7 тис.Рік тому
A REAL usecase of Golang Go Routines! - Golang Concurrency Example
Handling errors LIKE a 10x ENGINEER in Golang - Golang Service Pattern
Переглядів 28 тис.Рік тому
Handling errors LIKE a 10x ENGINEER in Golang - Golang Service Pattern
Hexagonal Architecture In Golang!? - Full Structure Example
Переглядів 17 тис.Рік тому
Hexagonal Architecture In Golang!? - Full Structure Example
How I went from Gamer to Software Engineer - UK
Переглядів 1,7 тис.Рік тому
How I went from Gamer to Software Engineer - UK
Implementing Comments - FULL Stack Golang SOCIAL MEDIA PLATFORM!
Переглядів 1 тис.Рік тому
Implementing Comments - FULL Stack Golang SOCIAL MEDIA PLATFORM!
BUILDING A SOCIAL MEDIA PLATFORM IN FULLSTACK GO!? - Introduction
Переглядів 2,4 тис.Рік тому
BUILDING A SOCIAL MEDIA PLATFORM IN FULLSTACK GO!? - Introduction
So you want to become a Software Engineer in 2024?
Переглядів 1 тис.Рік тому
So you want to become a Software Engineer in 2024?
Domain Driven Design (DDD) in Golang!?
Переглядів 22 тис.Рік тому
Domain Driven Design (DDD) in Golang!?
RAPIDLY Building Full Stack Apps in Golang
Переглядів 7 тис.Рік тому
RAPIDLY Building Full Stack Apps in Golang
Golang Dependency Injection Made EASY - The Repository Pattern
Переглядів 21 тис.Рік тому
Golang Dependency Injection Made EASY - The Repository Pattern

КОМЕНТАРІ

  • @whalebird
    @whalebird 5 годин тому

    wow : ) Looks clean!

  • @NavidRashik
    @NavidRashik 3 дні тому

    Where is the code snippet? You have shared your whole GitHub

  • @NickCorin
    @NickCorin 4 дні тому

    Isn't emitting an event before knowing that persistence was successful a bit premature? What happens if the service goes down before the user is stored, but another service consumed your event? I usually use my data layer (be it pg, or some other store) to set the fields like id, or the timestamp fields, then queue from the store to emit. Btw, great video. We need more hands on Go content!

  • @Rcls01
    @Rcls01 8 днів тому

    I've been learning Go as one of my goals in 2024, and unfortunately haven't had too many opportunities to use it because I've been working as a front-end engineer for two years (hopefully I can go back to backend next year), but this really helped me understand the usability of go routines! I already thought of a use case for it in my own application. I have an app that has one endpoint which stores purchase information from a mobile app (electronic cash register, ECR), to the database, and from the ECRs perspective it doesn't matter if that operation succeeds or fails; they've already made sure the money has been collected before it sends in that request to store the purchase information. Anyway, long story short, I had to set up a queue to make that whole thing asynchronous and faster for the ECR, so that it doesn't have to wait for the operation to finish, but goroutines would've probably saved me that headache. Too bad I wrote it in TypeScript. And finally, thanks for this short video!

  • @victoronah
    @victoronah 13 днів тому

    hey man it would have been cooler if one can see the github repo for this application trying to get an overview of how you structured you application.

  • @valentinrafael9201
    @valentinrafael9201 25 днів тому

    I didn't think of using hx-swap=#{{$id}}. That's so powerful. RIP JS ( even though htmx is js, we don't have to write as much js, if any at all )

  • @vedantmatanhelia1016
    @vedantmatanhelia1016 28 днів тому

    Why would we be using txn if we follow this pattern ?

  • @cesarclarosns
    @cesarclarosns Місяць тому

    If incrementing the view count fails you will end up with an inconsistency, the request that should have failed will be interpreted as succesfull...

  • @hectorcast943
    @hectorcast943 Місяць тому

    how do you handle db transaction in service pattern? like using 2 separate services in the handler function.

  • @AndreasHejndorf
    @AndreasHejndorf Місяць тому

    What’s your thoughts on using DTOs and newing up domain models in the service vs newing up in the adapters and parsing domain objects to services? I’ve seen both approaches and see pros and cons for both as well. What do you think about creating ports for the services as well? So the driving adapters are not depending directly on the services, but of a port of the service?

  • @asntechies8017
    @asntechies8017 Місяць тому

    Bro I am new to go just wanted to know is it h exagonal architecture?

  • @kqvanity
    @kqvanity Місяць тому

    6:55 I think you meant to name it GetUser instead

  • @davidalejandrocastiblancos1171
    @davidalejandrocastiblancos1171 Місяць тому

    but the fields should be private in the Domain layer

  • @christophercaldwell6641
    @christophercaldwell6641 Місяць тому

    What does this look like when you start to have 10, 20, 30 repos and services? How can you organize them with this pattern in mind? Are all of the services and repos created in main, and passed down through closures?

  • @prashlovessamosa
    @prashlovessamosa 2 місяці тому

    Bruv 5 months no upload

    • @samvcodes
      @samvcodes 2 місяці тому

      Videos coming soon! Do you have any suggestions?

  • @emehrkay
    @emehrkay 2 місяці тому

    This is good stuff. I dont see any example code your github that references this pattern, where can i see that? Thanks

  • @aleyrizvi
    @aleyrizvi 2 місяці тому

    I see your interface has return pointer to local *Profile. How does storage / postgres satisfy this? doesn't it introduce circular dependency if postgres is returning *customer.Profile?

  • @upulwaruna.abeysinghe
    @upulwaruna.abeysinghe 2 місяці тому

    a good video , great value

  • @patriciabonaldy9624
    @patriciabonaldy9624 2 місяці тому

    I thought you would show a rate limit by IP address to this endpoint, you're only adding it to the cache

  • @crusader_
    @crusader_ 3 місяці тому

    which font is this

  • @pasanmadhuranga9545
    @pasanmadhuranga9545 3 місяці тому

    you're an superstart bro😃😃

  • @lloydchapple403
    @lloydchapple403 3 місяці тому

    really useful thanks mate

  • @trashmail8
    @trashmail8 3 місяці тому

    4:10 You might find NATS interesting as an event broker. Since it's written in Go, you can even include the server it in your app and scale out to global levels later. ;)

  • @techzone-lk-zone3075
    @techzone-lk-zone3075 3 місяці тому

    Good ❤❤❤

  • @katungiyassin9947
    @katungiyassin9947 3 місяці тому

    Your teaching style is good keep up the good work.

  • @diogolisboa9976
    @diogolisboa9976 3 місяці тому

    You don't need the log level map to convert string to log level as slog.Level implements UnmarshalText. You can use flag.TextVar(&opts.logger.level, ...) instead of flag.StringVar and it'll happen automatically (go run ./main.go -log-level debug).

  • @losing_interest_in_everything
    @losing_interest_in_everything 3 місяці тому

    Do you think it is possible to create a UI component library that works alongside a CLI to generate static HTML files? I was searching for a good method to accomplish that.

  • @hereallyfast
    @hereallyfast 4 місяці тому

    I guess I have to get frustrated with life without templ to feel motivated to try it

  • @hereallyfast
    @hereallyfast 4 місяці тому

    Yeah, TEMPL seems a bit too much. I just want my tailwind in my go. I don't know what all the other stuff is. Does someone feel me on this?

  • @pratikkulkarni891
    @pratikkulkarni891 4 місяці тому

    Ah, I have used this pattern without knowing this is what Dependency Injection is. Thanks for this video.

  • @aftalavera
    @aftalavera 4 місяці тому

    Thanks for a very pragmatic example

  • @nooblero
    @nooblero 4 місяці тому

    So much code and you are still going to end up with thousand lines of "if err != nill" When people are asking for better error handling I am not sure that we worry about how to transfer error details, but rather how to make the code cleaner and less repetitive.

    • @toTheMuh
      @toTheMuh 8 днів тому

      less repetitive != cleaner

  • @AttilaOlbrich
    @AttilaOlbrich 4 місяці тому

    If the errs.Set method would deal with the second parameter "err" and would set the error only if it is not null, we could save a lot if "if err != nil {}", and email, err := input.Email() errs.Set("email", err) would be enough. Just an idea. Code readability may be compromised.

  • @samankarbasi1
    @samankarbasi1 4 місяці тому

    good content, tnx, but why background music??? it is hard to understand

  • @its-that-simple
    @its-that-simple 4 місяці тому

    Thanks for nice video and sharing your experience. your content is more advance. I found one more vdo on how to handle panic error, may be it will help others ua-cam.com/video/I64eE3OyEW0/v-deo.html sharing is caring.

  • @NiccoloFant
    @NiccoloFant 4 місяці тому

    Should domain service method params be passed as already validated domain objects or should they be provided as primitive types (like in this video)?

  • @chengkenlee
    @chengkenlee 4 місяці тому

    Yes, I learned

  • @anshkumargarhewal8582
    @anshkumargarhewal8582 5 місяців тому

    Which theme are you using

  • @valentineejk
    @valentineejk 5 місяців тому

    What of fiber rate limiter middleware

  • @SecurityM1nd
    @SecurityM1nd 5 місяців тому

    What is the benefit of this ?, if want help ppl learn golang show them how u start this project from scratch :)

  • @whatever-s3e
    @whatever-s3e 5 місяців тому

    noob question. Writing html element in a text file gives output to a browser. Why do we need a extra html template engine again? i could not get the whole functionality.

  • @lucifer-5ybtn
    @lucifer-5ybtn 5 місяців тому

    programming font name?

  • @johnxisde
    @johnxisde 5 місяців тому

    Since you have an invalid field, why should we waste cloud processing (seconds = $) to validate others? It looks nice, but it doesn't feel usable.

    • @samvcodes
      @samvcodes 5 місяців тому

      I suppose the argument to that is if a caller provides multiple invalid fields and you only return the first field you catch, and then have to make another call (another invocation) just to get another error response back with the other error field. So potentially you actually save $ (less invocations in cloud?) something to think about potentially? 😊

  • @0xff_1337
    @0xff_1337 6 місяців тому

    You just explained the general concept of DI, there was nothing specific to Go. The hard hard is, how do you register dependencies and create a system that automatically injects the correct dependency. Sorry but you missed the point.

    • @luanrodrigues4901
      @luanrodrigues4901 3 місяці тому

      Well, I don’t think it exactly did. The main package / file should be the only place where you resolve the dependencies (that is: instantiate db conn, repositories , services and any other object). It does not matter if you’re using a DI Container to resolve (i.g: Fx) or manually resolving it , as long as they are resolved at the main package. Your business layer only declares the constructor and its dependencies , who is resolving does not mattter to the business layer. :)

  • @worldwide6626
    @worldwide6626 6 місяців тому

    What linter do you use?

  • @TheMouseJerry-du1md
    @TheMouseJerry-du1md 6 місяців тому

    Great video and thank you for describing where in real time one can see such usage. You got me subscribed and thumbs-up!

  • @jbarnett7045
    @jbarnett7045 6 місяців тому

    'promo sm'

  • @marcosissler
    @marcosissler 6 місяців тому

    Thanks Sam! I am doing a huge research and learning more how to do a template or a basic structure to use in the project and is very hard as you know everyone do a different kind of organization. DDD, Clean Arch, Hex, DDD + Clean , omg! So, do you have some repo that represent this kind of structure that you are using? I like the *types that you use but not get so much how do you deal with the services and bus types. Do you have one service for each entity of your bus logic? Not sure if I separate the service from the type. Tks a lot! If you have any recommendation of project template or even a course that I can watch, do, see, search I will really appreciate. And thank you for your videos, they are an inspiration for me. Do you work as a freelancer?

  • @konradpiotrowski9549
    @konradpiotrowski9549 6 місяців тому

    Damn, this is nice. Imho it would be perfect if you finish it off with some dependency injection, specific error handler interface which is later on implemented by a few packages, http, grpc... So then when you switch from httperror to grpcerror you do it in one place by replacing the structure instead of refering to a different package everywhere :)

  • @nulblaze
    @nulblaze 6 місяців тому

    Had been reading a lot about contexts and goroutines but this video made a lightbulb go off in my head. The real world examples really help, thank you for that