setup

package module
v0.0.0-...-5a7b78d Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: GPL-3.0 Imports: 10 Imported by: 2

README

Basic setup helpers for microservices

We typically use sql, redis and datastore in our microservices

These provide some basic methods and structs to keep our microservice definition and structure consistent

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSafecilitySql

func NewSafecilitySql(config MySQLConfig) (*sql.DB, error)

NewSafecilitySql creates a new MySQL server.

Types

type Deployment

type Deployment string
const (
	LocalTest  Deployment = "local-test"
	Local      Deployment = "local"
	Test       Deployment = "test"
	Staging    Deployment = "staging"
	Production Deployment = "prod"
)

type MySQLConfig

type MySQLConfig struct {
	//dont json in password
	Password               string `json:"-"`
	Username               string `json:"user"`
	Host                   string `json:"host"`
	Port                   int    `json:"port"`
	Database               string `json:"database"`
	InstanceConnectionName string `json:"instanceConnectionName"`
}

type RedisConfig

type RedisConfig struct {
	Host string `json:"host"`
	Port string `json:"port"`
	Key  string `json:"key"`
}

func (*RedisConfig) Address

func (r *RedisConfig) Address() string

func (*RedisConfig) NewClient

func (r *RedisConfig) NewClient() *redis.Client

type Secret

type Secret struct {
	Name    string `json:"name"`
	Version int    `json:"version"`
}

type Secrets

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

func GetNewSecrets

func GetNewSecrets(projectID string, client *secretmanager.Client) *Secrets

GetNewSecrets - fix all the weird things in google's api

func (*Secrets) AddSecretVersion

func (s *Secrets) AddSecretVersion(secretName string, newPayload []byte) (*secretmanagerpb.SecretVersion, error)

func (*Secrets) GetSecret

func (s *Secrets) GetSecret(secret Secret) ([]byte, error)

GetSecret retrieve a secret with the given version name. The version name must comply with naming convention - auto is 1, 2 etc

func (*Secrets) SetSecret

func (s *Secrets) SetSecret(secretID string, payload []byte) (*secretmanagerpb.Secret, error)

func (*Secrets) UpdateSecret

func (s *Secrets) UpdateSecret(secret Secret, labels map[string]string) error

Jump to

Keyboard shortcuts

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