go-gousu

module
v2.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2023 License: MIT

README

Go Universal Service Utilities

Golang framework for writing lightweight microservices

GoDoc

Modules

Name Description
[gogousu] (https://github.com/indece-official/go-gousu) Core & utilities Module (dependency injection, logging, siem events, ...)
gogousujwt JWT-Verification
gogousukafka Kafka service & controller
gogousuredis Redis service
gogousupostgres Postgres service
gogoususmtp SMTP service
gogousuchi Chi controller

Usage

Example
package example

import "github.com/indece-official/go-gousu/gousu"

type TestService struct {
}

var _ (gousu.IService) = (*TestService)(nil)

func (s *TestService) Name() string  { return "test" }
func (s *TestService) Start() error  { return nil }
func (s *TestService) Health() error { return nil }
func (s *TestService) Stop() error   { return nil }

func NewTestService(ctx gousu.IContext) gousu.IService {
	return &TestService{}
}

type TestController struct {
	testService *TestService
}

var _ (gousu.IController) = (*TestController)(nil)

func (c *TestController) Name() string  { return "test" }
func (c *TestController) Start() error  { return nil }
func (c *TestController) Health() error { return nil }
func (c *TestController) Stop() error   { return nil }

func NewTestController(ctx gousu.IContext) gousu.IController {
	return &TestController{
		testService: ctx.GetService("test").(*TestService),
	}
}

func ExampleMain() {
	runner := gousu.NewRunner("example", "1.0.0")
	runner.CreateService(NewTestService)
	runner.CreateController(NewTestController)

	runner.Run()
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL