🚩Getting Started

Thunder is a collection of libraries and opinionated patterns to build cloud-native services. The project provides different modules, which can be used individually and replaced at any time.

Most of the modules use consolidated projects under the hood, the idea of this project is to provide wrappers and connect all of these pieces.

The modules are imported to the root of your app, you can then provide them to the rest of your project, below we're using Uber fx to perform the dependency injection.

// main.go
package main

import (
	transportinbound "github.com/gothunder/thunder/example/internal/transport-inbound"
	transportoutbound "github.com/gothunder/thunder/example/internal/transport-outbound"
	thunderEventRabbitmq "github.com/gothunder/thunder/pkg/events/rabbitmq"
	thunderLogs "github.com/gothunder/thunder/pkg/log"

	"github.com/rs/zerolog/diode"
	"go.uber.org/fx"
)

func main() {
	var w diode.Writer

	app := fx.New(
		// The order of these options isn't important.
		thunderLogs.Module,
		fx.Populate(&w),

		transportinbound.Module,
		transportoutbound.Module,

		thunderEventRabbitmq.PublisherModule,
		thunderEventRabbitmq.InvokeConsumer,
	)
	app.Run()

	// This is required to flush the logs to stdout.
	// We only want to do this after the app has exited.
	thunderLogs.DiodeShutdown(w)
}

Last updated