module

package
v0.0.0-...-e43c64b Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, params ...interface{})

Debug prints a debug message. If syslog is enabled then LOG_NOTICE is used

func Error

func Error(msg string, params ...interface{})

Error prints an error message. If syslog is enabled then LOG_ERR is used

func Fatal

func Fatal(msg string, params ...interface{})

Fatal logs Error and exits 1

func InitSyslog

func InitSyslog() (err error)

InitSyslog initializes logging to syslog

func SetLevel

func SetLevel(l Level)

SetLevel sets the log level

Types

type Etcd

type Etcd struct {
	Connection *clientv3.Client
}

Etcd struct

func NewEtcd

func NewEtcd() *Etcd

NewEtcd create a new instance

func (*Etcd) Connect

func (e *Etcd) Connect(address []string, dialTimeout int) error

Connect connects to etcd

func (*Etcd) Delete

func (e *Etcd) Delete(ctx context.Context, key string) *clientv3.DeleteResponse

Delete delete the value of a key

func (*Etcd) Disconnect

func (e *Etcd) Disconnect()

Disconnect closes etcd connection

func (*Etcd) Get

func (e *Etcd) Get(ctx context.Context, key string) *clientv3.GetResponse

Get get the value of a key

func (*Etcd) Put

func (e *Etcd) Put(ctx context.Context, key, value string) *clientv3.PutResponse

Put store a key value pair

type FileSystem

type FileSystem struct{}

FileSystem struct

func (*FileSystem) DirExists

func (fs *FileSystem) DirExists(path string) bool

DirExists reports whether the dir exists

func (*FileSystem) EnsureDir

func (fs *FileSystem) EnsureDir(dirName string, mode int) (bool, error)

EnsureDir ensures that directory exists

func (*FileSystem) FileExists

func (fs *FileSystem) FileExists(path string) bool

FileExists reports whether the named file exists

func (*FileSystem) PathExists

func (fs *FileSystem) PathExists(path string) bool

PathExists reports whether the path exists

type HTTPClient

type HTTPClient struct{}

HTTPClient struct

func NewHTTPClient

func NewHTTPClient() *HTTPClient

NewHTTPClient creates an instance of http client

func (*HTTPClient) BuildData

func (h *HTTPClient) BuildData(parameters map[string]string) string

BuildData build body data

func (*HTTPClient) BuildParameters

func (h *HTTPClient) BuildParameters(endpoint string, parameters map[string]string) (string, error)

BuildParameters add parameters to URL

func (*HTTPClient) Delete

func (h *HTTPClient) Delete(endpoint string, parameters map[string]string, headers map[string]string) (*http.Response, error)

Delete http call

func (*HTTPClient) Get

func (h *HTTPClient) Get(endpoint string, parameters map[string]string, headers map[string]string) (*http.Response, error)

Get http call

func (*HTTPClient) GetStatusCode

func (h *HTTPClient) GetStatusCode(response *http.Response) int

GetStatusCode response status code

func (*HTTPClient) Post

func (h *HTTPClient) Post(endpoint string, data string, parameters map[string]string, headers map[string]string) (*http.Response, error)

Post http call

func (*HTTPClient) Put

func (h *HTTPClient) Put(endpoint string, data string, parameters map[string]string, headers map[string]string) (*http.Response, error)

Put http call

func (*HTTPClient) ToString

func (h *HTTPClient) ToString(response *http.Response) (string, error)

ToString response body to string

type Level

type Level int

Level is a log level such a Debug or Error

const (

	// LevelDebug enables debug logging
	LevelDebug Level = iota
	// LevelError enables error logging
	LevelError Level = iota
)

type Rabbitmq

type Rabbitmq struct {
	Conn *amqp.Connection
	Addr string
}

Rabbitmq struct

func NewRabbitmq

func NewRabbitmq() *Rabbitmq

NewRabbitmq create a new instance

func (*Rabbitmq) Connect

func (r *Rabbitmq) Connect() (bool, error)

Connect connects to Rabbitmq

func (*Rabbitmq) Disconnect

func (r *Rabbitmq) Disconnect()

Disconnect closes the connection

func (*Rabbitmq) Listen

func (r *Rabbitmq) Listen(_ func(message string) error)

Listen listens to published messages

func (*Rabbitmq) Publish

func (r *Rabbitmq) Publish(queue string, message string) (bool, error)

Publish publish the message to rabbitmq

func (*Rabbitmq) SetAddr

func (r *Rabbitmq) SetAddr(addr string)

SetAddr sets rabbitmq address

Jump to

Keyboard shortcuts

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