services

package module
v0.0.0-...-87c1e71 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: MIT Imports: 21 Imported by: 37

README

common-services

Collection of commonly used services at webtor.io

Probe

Generates standard liveness and readiness probe endpoints for kubernetes

Serve

Runs simultaneously multiple services in goroutines

Example usage

package main

import (
	cs "github.com/webtor-io/common-services"
	log "github.com/sirupsen/logrus"
	"github.com/urfave/cli"
	s "github.com/webtor-io/torrent-http-proxy/services"
)

func configure(app *cli.App) {
	app.Flags = []cli.Flag{}

	s.RegisterWebFlags(app)
	cs.RegisterProbeFlags(app)

	app.Action = run
}

func run(c *cli.Context) error {
	// Setting ProbeService
	probe := cs.NewProbe(c)
	defer probe.Close()

	// Setting WebService
	web := s.NewWeb(c)
	defer web.Close()

	// Setting ServeService
	serve := cs.NewServe(probe, web)

	// And SERVE!
	err := serve.Serve()
	if err != nil {
		log.WithError(err).Error("Got serve error")
	}
	return err
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakePGMigrationCMD

func MakePGMigrationCMD() cli.Command

func RegisterPGFlags

func RegisterPGFlags(f []cli.Flag) []cli.Flag

func RegisterPprofFlags

func RegisterPprofFlags(f []cli.Flag) []cli.Flag

func RegisterProbeFlags

func RegisterProbeFlags(f []cli.Flag) []cli.Flag

RegisterProbeFlags registers cli flags for Probe

func RegisterPromFlags

func RegisterPromFlags(f []cli.Flag) []cli.Flag

func RegisterRedisClientFlags

func RegisterRedisClientFlags(f []cli.Flag) []cli.Flag

RegisterRedisClientFlags registers cli flags for RedisClient

func RegisterS3ClientFlags

func RegisterS3ClientFlags(f []cli.Flag) []cli.Flag

RegisterS3ClientFlags registers cli flags for S3 client

Types

type PG

type PG struct {
	// contains filtered or unexported fields
}

func NewPG

func NewPG(c *cli.Context) *PG

func (*PG) Close

func (s *PG) Close()

func (*PG) Get

func (s *PG) Get() *pg.DB

type PGMigration

type PGMigration struct {
	// contains filtered or unexported fields
}

func NewPGMigration

func NewPGMigration(db *PG) *PGMigration

func (*PGMigration) Run

func (s *PGMigration) Run(a ...string) error

type Pprof

type Pprof struct {
	// contains filtered or unexported fields
}

func NewPprof

func NewPprof(c *cli.Context) *Pprof

func (*Pprof) Close

func (s *Pprof) Close()

func (*Pprof) Serve

func (s *Pprof) Serve() error

type Probe

type Probe struct {
	// contains filtered or unexported fields
}

Probe provides simple HTTP-service for Kubernetes liveness and readiness checking

func NewProbe

func NewProbe(c *cli.Context) *Probe

NewProbe initializes new Probe instance

func (*Probe) Close

func (s *Probe) Close()

Close closes Probe web service

func (*Probe) Serve

func (s *Probe) Serve() error

Serve serves Probe web service

type Prom

type Prom struct {
	// contains filtered or unexported fields
}

func NewProm

func NewProm(c *cli.Context) *Prom

func (*Prom) Close

func (s *Prom) Close()

func (*Prom) Serve

func (s *Prom) Serve() error

type RedisClient

type RedisClient struct {
	// contains filtered or unexported fields
}

RedisClient makes Redis Client from cli and environment variables Automatically hanldles Sentinel configuration

func NewRedisClient

func NewRedisClient(c *cli.Context) *RedisClient

NewRedisClient initializes RedisClient

func (*RedisClient) Close

func (s *RedisClient) Close()

Close closes RedisClient

func (*RedisClient) Get

Get gets redis.UniversalCleint

type S3Client

type S3Client struct {
	// contains filtered or unexported fields
}

S3Client makes AWS SDK S3 Client from cli and environment variables

func NewS3Client

func NewS3Client(c *cli.Context, cl *http.Client) *S3Client

NewS3Client initializes S3Client

func (*S3Client) Get

func (s *S3Client) Get() *s3.S3

Get get AWS SDK S3 Client

type Servable

type Servable interface {
	Serve() error
}

Servable serves something

type Serve

type Serve struct {
	// contains filtered or unexported fields
}

Serve serves multible Servables at ones, handles errors and system signals

func NewServe

func NewServe(s ...Servable) *Serve

NewServe initializes Serve

func (*Serve) Serve

func (s *Serve) Serve() error

Serve serves multible Servables

Jump to

Keyboard shortcuts

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