servicebase

package module
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: May 25, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

README

NOT MEANT TO BE USED

This is just a place I am testing some mongo modules I am putting together. I use this to rapidly onboard go based apps for kubernetes use. Very alpha very incomplete but i'll be adding more to t and cleaning things up. Not meant for prod use just demo boilerplate stuff.

Table of Contents

General Usage

import (
  serviceBase "github.com/axodevelopment/servicebase"
)


func main() {

  var svc *serviceBase.Service

  svc, _ = serviceBase.New("AirportApp", serviceBase.WithPort(9091), serviceBase.WithHealthProbe(true))


	/*
    Do whatever you want
  */

  svc.AppHealthz = true
  svc.AppReadyz = true

	//start the backend
	go func(s *serviceBase.Service) {
		serviceBase.Start(s)
	}(svc)

	<-svc.ExitAppChan
}

Goal here is this will wrap up GIN and health / ready probes etc so you can just to get to making routes etc.


func createAirportRoutes(svc *serviceBase.Service) {
	svc.GinEngine.GET("/route", func(ctx *gin.Context) {

		/// do stuff
    ctx.JSON(http.StatusOK, data)

	})
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Start added in v0.0.3

func Start(svc *Service)

Types

type Option added in v0.0.3

type Option func(*Service)

func WithCORS added in v0.0.8

func WithCORS(enable bool) Option

func WithHealthProbe added in v0.0.3

func WithHealthProbe(healthProbe bool) Option

func WithPort added in v0.0.3

func WithPort(port int) Option

func WithVersion added in v0.0.3

func WithVersion(version int) Option

type Service

type Service struct {
	//public
	Name        string          `json:"Name"`
	Port        int             `json:"Port"`
	HealthProbe bool            `json:"HealthProbe"`
	ExitAppChan <-chan struct{} `json:"-"`
	GinEngine   *gin.Engine     `json:"-"`
	AppHealthz  bool            `json:"AppHealthz"`
	AppReadyz   bool            `json:"AppReadyz"`
	Version     int             `json:"Version"`
	CORSEnabled bool            `json:"CorsEnabled"`
	// contains filtered or unexported fields
}

func New

func New(name string, options ...Option) (*Service, error)

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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