utils

package
v1.2.47 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: MIT Imports: 16 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DockerUtils added in v1.1.5

func DockerUtils() (du *dockerUtils)

DockerUtils is a simple utility to execute docker commands using shell This utility does not us the docker client library (due to compatability issues) but instead utilizes the shell command executor (from os/exec package). The pre-requisite

func HashUtils

func HashUtils() *hashUtils

HashUtils is a factory method that acts as a static member

func JsonUtils

func JsonUtils() *jsonUtils

JsonUtils factory method

func RecoverAll

func RecoverAll(cb func(v any))

RecoverAll performs recover for all panics.

Sample usage:

defer RecoverAll(func(err any) {
	fmt.Printf("got error: %s", err)
})

func RecoverAny

func RecoverAny(errors []error, cb func(v any))

RecoverAny calls the callback function: cb with recovered value in case when recovered value exists in slice errors.

Sample usage:

		defer recover.Any([]error{ErrorUsernameBlank, ErrorUsernameAlreadyTaken}, func(err any) {
 		fmt.Printf("got error: %s", err)
		})

func RecoverOne

func RecoverOne(e error, cb func(v any))

RecoverOne calls the callback function: cb with recovered value in case when recovered value equals to e otherwise panic won't be recovered and will be propagated.

Sample usage:

defer recover.One(ErrorUsernameBlank, func(err any) {
	fmt.Printf("got error: %s", err)
})

func SetAPISecret added in v1.1.2

func SetAPISecret(secret, vector string) error

SetAPISecret set the secret key and initializing vector to encode/decode API keys

func SetJWTSecret added in v1.1.2

func SetJWTSecret(secret string) error

SetJWTSecret set the private key to sign JWT token

func TimeUtils added in v1.2.26

func TimeUtils(ts Timestamp) *timeUtils

TimeUtils is a factory method

func TokenUtils added in v1.1.2

func TokenUtils() *tokenUtils

TokenUtils is a factory method that acts as a static member

Types

type DockerContainer added in v1.1.5

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

DockerContainer is used to construct docker container spec for the docker engine.

func (*DockerContainer) AutoRemove added in v1.1.5

func (c *DockerContainer) AutoRemove(value bool) *DockerContainer

AutoRemove determines whether to automatically remove the container when it has stopped

func (*DockerContainer) EntryPoint added in v1.1.5

func (c *DockerContainer) EntryPoint(args ...string) *DockerContainer

EntryPoint sets the entrypoint arguments of the container.

func (*DockerContainer) Exists added in v1.1.5

func (c *DockerContainer) Exists() bool

Exists return true if the container exists

func (*DockerContainer) IsRunning added in v1.1.7

func (c *DockerContainer) IsRunning() bool

IsRunning return true if the container exists and running

func (*DockerContainer) Label added in v1.1.5

func (c *DockerContainer) Label(label, value string) *DockerContainer

Label adds custom label

func (*DockerContainer) Labels added in v1.1.5

func (c *DockerContainer) Labels(label map[string]string) *DockerContainer

Labels adds multiple labels

func (*DockerContainer) Name added in v1.1.5

func (c *DockerContainer) Name(value string) *DockerContainer

Name sets the container name.

func (*DockerContainer) Port added in v1.1.5

func (c *DockerContainer) Port(external, internal string) *DockerContainer

Port adds a port mapping

func (*DockerContainer) Ports added in v1.1.5

func (c *DockerContainer) Ports(ports map[string]string) *DockerContainer

Ports adds multiple port mappings

func (*DockerContainer) Run added in v1.1.5

func (c *DockerContainer) Run() error

Run builds and run command

func (*DockerContainer) Stop added in v1.1.5

func (c *DockerContainer) Stop() error

Stop and kill container

func (*DockerContainer) Var added in v1.1.5

func (c *DockerContainer) Var(key, value string) *DockerContainer

Var adds an environment variable

func (*DockerContainer) Vars added in v1.1.5

func (c *DockerContainer) Vars(vars map[string]string) *DockerContainer

Vars adds multiple environment variables

Directories

Path Synopsis
Package cache Cache item implementation Based on https://github.com/ReneKroon/ttlcache
Package cache Cache item implementation Based on https://github.com/ReneKroon/ttlcache

Jump to

Keyboard shortcuts

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