services

package
v1.2.140 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: GPL-3.0 Imports: 24 Imported by: 3

Documentation

Overview

Package services для подключения сервисов и устроения взаимодействия сервисов с главным потоком

Index

Constants

View Source
const (
	ShowStatus         = "/api/status/"
	ShowDBStatus       = "/api/status/db"
	ShowPsqlLog        = "/api/status/psql"
	ShowStatusServices = "/api/status/services"
	ShowLog            = "/api/log/"
	ShowDebugLog       = "/api/log/debug/"
	ShowErrorsLog      = "/api/log/errors/"
	ShowFEUpdateLog    = "/api/log/errors/front/update/"
	ShowInfoLog        = "/api/log/info/"
)
View Source
const PATH_FLAG = "-path"

PATH_FLAG - сиситемая константа - флаг пути к файлам конфигурации.

View Source
const (
	SHOW_LOG_CMD = "show_log_cmd"
)

param of log showing

View Source
const STATUS_ERROR = "error"

STATUS_ERROR - стстус Сервиса - "Ошибка"

View Source
const STATUS_PREPARING = "preparing data"

STATUS_PREPARING - стстус Сервиса - "Подготовка сервиса"

View Source
const STATUS_READY = "ready"

STATUS_READY - стстус Сервиса - "Готово"

View Source
const TYPE_HTML = "text/html"

TYPE_HTML - тип отправляемого сообщения - "HTML"

View Source
const TYPE_PLAIN_TEXT = "text/plain"

TYPE_PLAIN_TEXT - тип отправляемого сообщения - "Текст"

Variables

This section is empty.

Functions

func AddService

func AddService(name string, pService IService)

AddService adding new service with {name} to services list

func Close

func Close(name string, out chan<- interface{}) error

Close service {name}

func Connect

func Connect(name string, in <-chan interface{}) (out chan interface{}, err error)

Connect to service {name} from channel in & return channel service

func DoGetRequest

func DoGetRequest(url string, hdr *fasthttp.RequestHeader) (*fasthttp.Response, error)

func DoPostJSONRequest added in v1.2.105

func DoPostJSONRequest(url string, json []byte, hdr *fasthttp.RequestHeader) (*fasthttp.Response, error)

func DoPostRequest added in v1.2.57

func DoPostRequest(url string, params map[string]string, hdr *fasthttp.RequestHeader) (*fasthttp.Response, error)

func DoRequest

func DoRequest(url string, params map[string]string) (*fasthttp.Response, error)

func DoRequestAndKeep

func DoRequestAndKeep(url string, params map[string]string, ch chan<- *fasthttp.Response) error

func ExampLeSendEmail

func ExampLeSendEmail()

ExampLeSendEmail - пример отправки сообщения

func GeneratePassword

func GeneratePassword(email string) (string, error)

GeneratePassword run password by email

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateRandomString

func GenerateRandomString(s int) (string, error)

GenerateRandomString returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func Get

func Get(ctx context.Context, name string, messages ...interface{}) (response interface{}, err error)

Get messages to service {name} & return result

func HandleShowDebugServer

func HandleShowDebugServer(ctx *fasthttp.RequestCtx) (interface{}, error)

HandleShowDebugServer show debug messages @/api/log/debug/

func HandleShowErrorsServer

func HandleShowErrorsServer(ctx *fasthttp.RequestCtx) (interface{}, error)

HandleShowErrorsServer show services errors @/api/log/errors/

func HandleShowLogServer

func HandleShowLogServer(ctx *fasthttp.RequestCtx) (interface{}, error)

HandleShowLogServer show logs messages @/api/log/

func HandleShowPostgresLog

func HandleShowPostgresLog(ctx *fasthttp.RequestCtx) (interface{}, error)

HandleShowPostgresLog show services errors @/api/status/psql

func HandleShowStatusServer

func HandleShowStatusServer(ctx *fasthttp.RequestCtx) (interface{}, error)

HandleShowStatusServer show status message @/api/log/info/

func HandleStatusDB

func HandleStatusDB(ctx *fasthttp.RequestCtx) (interface{}, error)

HandleStatusDB show current processes of DB @/api/status/

func HandleStatusServer

func HandleStatusServer(ctx *fasthttp.RequestCtx) (interface{}, error)

HandleStatusServer show status of httpgo @/api/status/

func HandleStatusServices

func HandleStatusServices(ctx *fasthttp.RequestCtx) (interface{}, error)

HandleStatusServices show status of local services @/api/status/services

func HashPassword

func HashPassword(password []byte) uint32

HashPassword create hash from {password} & return checksumm

func RunGrep

func RunGrep(stdout []byte, params ...string) ([]byte, error)

func RunPostgresqlLog

func RunPostgresqlLog(params string) ([]byte, error)

func Send

func Send(ctx context.Context, name string, messages ...interface{}) (err error)

Send messages to service {name}

func Status

func Status(name string) string

Status service {name} return

func VerifyMail

func VerifyMail(email, password string)

VerifyMail - проверка на валидность email - адреса

Types

type ErrBrokenConnection

type ErrBrokenConnection struct {
	Name  string
	Param interface{}
}

ErrBrokenConnection for errors broken connection

func (ErrBrokenConnection) Error

func (err ErrBrokenConnection) Error() string

type ErrServiceNotCorrectOperation

type ErrServiceNotCorrectOperation struct {
	Name     string
	OperName string
	Message  string
}

ErrServiceNotCorrectOperation for errors if input operation is not valid

func (ErrServiceNotCorrectOperation) Error

type ErrServiceNotCorrectParamType

type ErrServiceNotCorrectParamType struct {
	Name   string
	Number int
	Param  interface{}
}

ErrServiceNotCorrectParamType for errors if parameter is not valid

func (ErrServiceNotCorrectParamType) Error

type ErrServiceNotEnoughParameter

type ErrServiceNotEnoughParameter struct {
	Name  string
	Param interface{}
}

ErrServiceNotEnoughParameter for errors if not found required parameter

func (ErrServiceNotEnoughParameter) Error

type ErrServiceNotFound

type ErrServiceNotFound struct {
	Name string
}

ErrServiceNotFound for errors when current service not found

func (ErrServiceNotFound) Error

func (err ErrServiceNotFound) Error() string

type ErrServiceNotReady

type ErrServiceNotReady struct {
	Name   string
	Status string
}

ErrServiceNotReady for errors if service not ready

func (ErrServiceNotReady) Error

func (err ErrServiceNotReady) Error() string

type ErrServiceWrongIndex

type ErrServiceWrongIndex struct {
	Name  string
	Index int
}

ErrServiceWrongIndex for errors wrong index in array range TODO: wrote correct comment for this type

func (ErrServiceWrongIndex) Error

func (err ErrServiceWrongIndex) Error() string

type IChildService

type IChildService interface {
	Dependencies() []IService
	IsReadyToStart() bool
}

IChildService interface of service with parent dependencies

type IService

type IService interface {
	Init(ctx context.Context) error
	Send(ctx context.Context, messages ...interface{}) error
	Get(ctx context.Context, messages ...interface{}) (response interface{}, err error)
	Connect(in <-chan interface{}) (out chan interface{}, err error)
	Close(out chan<- interface{}) error
	Status() string
}

IService root service interface

type Mail

type Mail struct {
	From        string
	To          string
	Subject     string
	ContentType string
	Body        string
	Attachments []string
}

Mail - тип данных для письма

type RootServices added in v1.2.114

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

func InitServices

func InitServices(ctx context.Context, list ...string) *RootServices

InitServices started all services from sServices.services in some goroutins

type ShowLogsEngine

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

func (ShowLogsEngine) Close

func (s ShowLogsEngine) Close(out chan<- interface{}) error

func (ShowLogsEngine) Connect

func (s ShowLogsEngine) Connect(in <-chan interface{}) (out chan interface{}, err error)

func (ShowLogsEngine) Get

func (s ShowLogsEngine) Get(ctx context.Context, messages ...interface{}) (response interface{}, err error)

func (ShowLogsEngine) Init

func (s ShowLogsEngine) Init(ctx context.Context) error

func (ShowLogsEngine) Send

func (s ShowLogsEngine) Send(ctx context.Context, messages ...interface{}) error

func (ShowLogsEngine) Status

func (s ShowLogsEngine) Status() string

Jump to

Keyboard shortcuts

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