service

package
v0.0.0-...-435b0f4 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: GPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLockMemNotReleased = service_error.NewServiceError(service_error.ErrCodeConflict, errors.New("lock: could not release lock"))
)
View Source
var (
	ErrPrometheusMetricAlreadyRegistered = service_error.NewServiceError(service_error.ErrCodeConflict, errors.New("metric already exists"))
)

Functions

This section is empty.

Types

type ActionInvocationService

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

func (*ActionInvocationService) CleanStale

func (s *ActionInvocationService) CleanStale(time time.Time, maxRetries int, state ...constant.ActionInvocationState) (int64, error)

func (*ActionInvocationService) Count

func (s *ActionInvocationService) Count() (int64, error)

func (*ActionInvocationService) Create

func (*ActionInvocationService) Delete

func (s *ActionInvocationService) Delete(id string) error

func (*ActionInvocationService) Enqueue

func (s *ActionInvocationService) Enqueue(batchSize int) error

func (*ActionInvocationService) EnqueueFromEvent

func (s *ActionInvocationService) EnqueueFromEvent(event *model.Event, actions []*model.Action) error

func (*ActionInvocationService) Execute

func (s *ActionInvocationService) Execute(action *model.Action, eventPayloadInfo *dto.EventPayloadInformationDto) error

func (*ActionInvocationService) Get

func (*ActionInvocationService) GetByState

func (s *ActionInvocationService) GetByState(limit int, maxRetries int, state ...constant.ActionInvocationState) ([]*model.ActionInvocation, error)

func (*ActionInvocationService) Invoke

func (s *ActionInvocationService) Invoke(batchSize int, maxRetries int) error

func (*ActionInvocationService) Paginate

func (s *ActionInvocationService) Paginate(page int, pageSize int, orderBy string, order string) ([]*model.ActionInvocation, error)

func (*ActionInvocationService) UpdateMessage

func (s *ActionInvocationService) UpdateMessage(id string, message *string) (*model.ActionInvocation, error)

func (*ActionInvocationService) UpdateRetryCount

func (s *ActionInvocationService) UpdateRetryCount(id string, retryCount int) (*model.ActionInvocation, error)

func (*ActionInvocationService) UpdateState

type ActionService

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

func (*ActionService) Count

func (s *ActionService) Count() (int64, error)

func (*ActionService) Create

func (s *ActionService) Create(label string, t constant.ActionType, matchEvent *string, matchHost *string, matchApplication *string, matchProvider *string, payload interface{}, enabled bool) (*model.Action, error)

func (*ActionService) Delete

func (s *ActionService) Delete(id string) error

func (*ActionService) Get

func (s *ActionService) Get(id string) (*model.Action, error)

func (*ActionService) GetAll

func (s *ActionService) GetAll() ([]*model.Action, error)

func (*ActionService) GetByEnabled

func (s *ActionService) GetByEnabled(enabled bool) ([]*model.Action, error)

func (*ActionService) IsValidPayload

func (s *ActionService) IsValidPayload(t constant.ActionType, payload interface{}) (bool, error)

func (*ActionService) Paginate

func (s *ActionService) Paginate(page int, pageSize int, orderBy string, order string) ([]*model.Action, error)

func (*ActionService) UpdateEnabled

func (s *ActionService) UpdateEnabled(id string, enabled bool) (*model.Action, error)

func (*ActionService) UpdateLabel

func (s *ActionService) UpdateLabel(id string, label string) (*model.Action, error)

func (*ActionService) UpdateMatchApplication

func (s *ActionService) UpdateMatchApplication(id string, matchApplication *string) (*model.Action, error)

func (*ActionService) UpdateMatchEvent

func (s *ActionService) UpdateMatchEvent(id string, matchEvent *string) (*model.Action, error)

func (*ActionService) UpdateMatchHost

func (s *ActionService) UpdateMatchHost(id string, matchHost *string) (*model.Action, error)

func (*ActionService) UpdateMatchProvider

func (s *ActionService) UpdateMatchProvider(id string, matchProvider *string) (*model.Action, error)

func (*ActionService) UpdateTypeAndPayload

func (s *ActionService) UpdateTypeAndPayload(id string, t constant.ActionType, payload interface{}) (*model.Action, error)

type ActionsCleanTask

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

func (*ActionsCleanTask) Init

func (s *ActionsCleanTask) Init() error

Init initializes background tasks for the service, should be called directly after NewActionsCleanTask

type ActionsEnqueueTask

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

func (*ActionsEnqueueTask) Init

func (s *ActionsEnqueueTask) Init() error

Init initializes background tasks for the service, should be called directly after NewActionsEnqueueTask

type ActionsInvokeTask

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

func (*ActionsInvokeTask) Init

func (s *ActionsInvokeTask) Init() error

Init initializes background tasks for the service, should be called directly after NewActionsInvokeTask

type AuthSessionCleanTask

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

func NewAuthSessionCleanTask

func NewAuthSessionCleanTask(c *config.Auth, t *TaskService) *AuthSessionCleanTask

func (*AuthSessionCleanTask) GetCleanupFn

type CommentService

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

func (*CommentService) CountByUpdateId

func (s *CommentService) CountByUpdateId(updateId string) (int64, error)

func (*CommentService) Create

func (s *CommentService) Create(author string, content string, update *model.Update) (*model.Comment, error)

func (*CommentService) Delete

func (s *CommentService) Delete(id string) error

func (*CommentService) GetById

func (s *CommentService) GetById(id string) (*model.Comment, error)

func (*CommentService) GetByUpdateId

func (s *CommentService) GetByUpdateId(updateId string, page int, pageSize int) ([]*model.Comment, error)

func (*CommentService) UpdateContent

func (s *CommentService) UpdateContent(id string, content string) (*model.Comment, error)

type ConstantService

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

func (*ConstantService) Delete

func (s *ConstantService) Delete(id string) error

func (*ConstantService) Get

func (s *ConstantService) Get(id string) (*model.Constant, error)

func (*ConstantService) GetAll

func (s *ConstantService) GetAll() ([]*model.Constant, error)

func (*ConstantService) GetValueByKey

func (s *ConstantService) GetValueByKey(key string) (string, error)

func (*ConstantService) Insert

func (s *ConstantService) Insert(key string, value string) (*model.Constant, error)

func (*ConstantService) UpdateValue

func (s *ConstantService) UpdateValue(id string, value string) (*model.Constant, error)

type EventService

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

func NewEventService

func NewEventService(r repository.EventRepository) *EventService

func (*EventService) CleanStale

func (s *EventService) CleanStale(time time.Time, state ...constant.EventState) (int64, error)

func (*EventService) Count

func (s *EventService) Count(state ...constant.EventState) (int64, error)

func (*EventService) Create

func (s *EventService) Create(name constant.EventName, payload interface{}) (*model.Event, error)

func (*EventService) CreateUpdateCreated

func (s *EventService) CreateUpdateCreated(e *model.Update) *model.Event

func (*EventService) CreateUpdateDeleted

func (s *EventService) CreateUpdateDeleted(e *model.Update) *model.Event

func (*EventService) CreateUpdateUpdated

func (s *EventService) CreateUpdateUpdated(old *model.Update, new *model.Update) *model.Event

func (*EventService) CreateWithWarnOnly

func (s *EventService) CreateWithWarnOnly(name constant.EventName, payload interface{}) *model.Event

func (*EventService) Delete

func (s *EventService) Delete(id string) error

func (*EventService) ExtractPayloadInfo

func (s *EventService) ExtractPayloadInfo(event *model.Event) (*dto.EventPayloadInformationDto, error)

func (*EventService) Get

func (s *EventService) Get(id string) (*model.Event, error)

func (*EventService) GetByState

func (s *EventService) GetByState(limit int, state ...constant.EventState) ([]*model.Event, error)

func (*EventService) UpdateState

func (s *EventService) UpdateState(id string, state constant.EventState) (*model.Event, error)

func (*EventService) Window

func (s *EventService) Window(size int, skip int, orderBy string, order string, updateId *string) ([]*model.Event, error)

func (*EventService) WindowHasNext

func (s *EventService) WindowHasNext(size int, skip int, orderBy string, order string, updateId *string) (bool, error)

type EventsCleanTask

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

func NewEventsCleanTask

func NewEventsCleanTask(e *EventService, t *TaskService, c *config.Task) *EventsCleanTask

func (*EventsCleanTask) Init

func (s *EventsCleanTask) Init() error

Init initializes background tasks for the service, should be called directly after NewEventsCleanTask

type FilterPresetService

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

func (*FilterPresetService) Create

func (s *FilterPresetService) Create(t constant.FilterPresetType, label string, parameters string, color *string) (*model.FilterPreset, error)

func (*FilterPresetService) Delete

func (s *FilterPresetService) Delete(id string) error

func (*FilterPresetService) GetByType

type Lock

type Lock interface {
	// Unlock unlocks a Lock
	Unlock(ctx context.Context) error
}

type LockMemService

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

func (*LockMemService) Lock

func (s *LockMemService) Lock(ctx context.Context, resource string) (Lock, error)

Lock locks a given resource without any options (default expiration)

func (*LockMemService) LockWithOptions

func (s *LockMemService) LockWithOptions(_ context.Context, resource string, options ...LockOption) (Lock, error)

LockWithOptions locks a given resource, only TTL as option is supported

type LockOption

type LockOption interface {
	Apply(l *LockOptions)
}

func WithLockExpiry

func WithLockExpiry(expiry time.Duration) LockOption

func WithLockInfiniteRetries

func WithLockInfiniteRetries() LockOption

func WithLockRetries

func WithLockRetries(retries int) LockOption

func WithLockRetryDelay

func WithLockRetryDelay(retryDelay time.Duration) LockOption

type LockOptionFunc

type LockOptionFunc func(o *LockOptions)

func (LockOptionFunc) Apply

func (f LockOptionFunc) Apply(o *LockOptions)

type LockOptions

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

type LockRedisService

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

func (*LockRedisService) Lock

func (s *LockRedisService) Lock(ctx context.Context, resource string) (Lock, error)

Lock locks a given resource without any options

func (*LockRedisService) LockWithOptions

func (s *LockRedisService) LockWithOptions(ctx context.Context, resource string, options ...LockOption) (Lock, error)

LockWithOptions locks a given resource considering all options

type LockService

type LockService interface {
	// Lock locks a resource applying default options (varies for implementations)
	Lock(ctx context.Context, resource string) (Lock, error)

	// LockWithOptions locks a resource with given options, not all options are applied (varies for implementations)
	LockWithOptions(ctx context.Context, resource string, options ...LockOption) (Lock, error)
}

LockService provides methods for locking resources, behavior depends on underlying implementation

func NewLockMemService

func NewLockMemService() LockService

func NewLockRedisService

func NewLockRedisService(lc *config.Lock) (LockService, error)

type PrometheusService

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

func NewPrometheusService

func NewPrometheusService(e *gin.Engine, c *config.Prometheus) *PrometheusService

func (*PrometheusService) GetProm

func (s *PrometheusService) GetProm() *ginprom.Prometheus

GetProm returns the to be instrumented prometheus registry for gin

func (*PrometheusService) IncreaseCounter

func (s *PrometheusService) IncreaseCounter(name string, labelValues []string) error

IncreaseCounter sets a metric

func (*PrometheusService) IncreaseCounterNoLabels

func (s *PrometheusService) IncreaseCounterNoLabels(name string) error

IncreaseCounterNoLabels sets a metric

func (*PrometheusService) RegisterCounter

func (s *PrometheusService) RegisterCounter(name string, help string, labels []string) error

RegisterCounter registers a metric

func (*PrometheusService) RegisterCounterNoLabels

func (s *PrometheusService) RegisterCounterNoLabels(name string, help string) error

RegisterCounterNoLabels registers a metric

func (*PrometheusService) RegisterGauge

func (s *PrometheusService) RegisterGauge(name string, help string, labels []string) error

RegisterGauge registers a metric

func (*PrometheusService) RegisterGaugeNoLabels

func (s *PrometheusService) RegisterGaugeNoLabels(name string, help string) error

RegisterGaugeNoLabels registers a metric

func (*PrometheusService) SetGauge

func (s *PrometheusService) SetGauge(name string, labelValues []string, value float64) error

SetGauge sets a metric

func (*PrometheusService) SetGaugeNoLabels

func (s *PrometheusService) SetGaugeNoLabels(name string, value float64) error

SetGaugeNoLabels sets a metric

type PrometheusTask

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

func (*PrometheusTask) Init

func (s *PrometheusTask) Init() error

Init initializes background tasks for the service, should be called directly after NewPrometheusTask

type SecretService

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

func (*SecretService) Delete

func (s *SecretService) Delete(id string) error

func (*SecretService) Get

func (s *SecretService) Get(id string) (*model.Secret, error)

func (*SecretService) GetAll

func (s *SecretService) GetAll() ([]*model.Secret, error)

func (*SecretService) GetValueByKey

func (s *SecretService) GetValueByKey(key string) (string, error)

func (*SecretService) Insert

func (s *SecretService) Insert(key string, value string) (*model.Secret, error)

func (*SecretService) UpdateValue

func (s *SecretService) UpdateValue(id string, value string) (*model.Secret, error)

type TaskService

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

func NewTaskService

func NewTaskService(l LockService, ac *config.App, lc *config.Lock) (*TaskService, error)

NewTaskService constructs the service, ensuring bootstrapped connection to potential redis works

func (*TaskService) Cancel

func (s *TaskService) Cancel(id uuid.UUID) error

Cancel cancels a job by ID

func (*TaskService) CancelByTag

func (s *TaskService) CancelByTag(tags ...string)

CancelByTag cancels a job by tags

func (*TaskService) Enqueue

func (s *TaskService) Enqueue(job gocron.JobDefinition, task gocron.Task, name string, options ...gocron.JobOption) (gocron.Job, error)

Enqueue enqueues a new job

func (*TaskService) EnqueueOnce

func (s *TaskService) EnqueueOnce(job gocron.JobDefinition, task gocron.Task, name string, options ...gocron.JobOption) (gocron.Job, error)

EnqueueOnce enqueues a new job once for execution, convenience method for gocron.WithLimitedRuns, see https://github.com/go-co-op/gocron/issues/709

func (*TaskService) Start

func (s *TaskService) Start()

Start starts the scheduler, should be called after Init

func (*TaskService) Stop

func (s *TaskService) Stop()

Stop stops the service and shuts down the scheduler

type UpdateService

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

func (*UpdateService) CleanStale

func (s *UpdateService) CleanStale(time time.Time, state ...constant.UpdateState) (int64, error)

func (*UpdateService) Count

func (s *UpdateService) Count(searchTerm string, searchIn string, state ...constant.UpdateState) (int64, error)

func (*UpdateService) Delete

func (s *UpdateService) Delete(id string) error

func (*UpdateService) Get

func (s *UpdateService) Get(id string) (*model.Update, error)

func (*UpdateService) GetAll

func (s *UpdateService) GetAll() ([]*model.Update, error)

func (*UpdateService) Paginate

func (s *UpdateService) Paginate(page int, pageSize int, orderBy string, order string, searchTerm string, searchIn string, state ...constant.UpdateState) ([]*model.Update, error)

func (*UpdateService) UpdateState

func (s *UpdateService) UpdateState(id string, state constant.UpdateState) (*model.Update, error)

func (*UpdateService) Upsert

func (s *UpdateService) Upsert(application string, provider string, host string, version string, metadata interface{}) (*model.Update, error)

type UpdatesCleanTask

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

func NewUpdatesCleanTask

func NewUpdatesCleanTask(u *UpdateService, t *TaskService, c *config.Task) *UpdatesCleanTask

func (*UpdatesCleanTask) Init

func (s *UpdatesCleanTask) Init() error

Init initializes background tasks for the service, should be called directly after NewUpdatesCleanTask

type WebhookInvocationService

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

func (*WebhookInvocationService) ExecuteDiun

func (s *WebhookInvocationService) ExecuteDiun(id string, token string, req api.WebhookDiunRequest) error

func (*WebhookInvocationService) ExecuteGeneric

func (s *WebhookInvocationService) ExecuteGeneric(id string, token string, req api.WebhookGenericRequest) error

type WebhookService

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

func (*WebhookService) Count

func (s *WebhookService) Count() (int64, error)

func (*WebhookService) Create

func (s *WebhookService) Create(label string, t constant.WebhookType, ignoreHost bool) (*model.Webhook, error)

func (*WebhookService) Delete

func (s *WebhookService) Delete(id string) error

func (*WebhookService) Get

func (s *WebhookService) Get(id string) (*model.Webhook, error)

func (*WebhookService) Paginate

func (s *WebhookService) Paginate(page int, pageSize int, orderBy string, order string) ([]*model.Webhook, error)

func (*WebhookService) UpdateIgnoreHost

func (s *WebhookService) UpdateIgnoreHost(id string, ignoreHost bool) (*model.Webhook, error)

func (*WebhookService) UpdateLabel

func (s *WebhookService) UpdateLabel(id string, label string) (*model.Webhook, error)

Jump to

Keyboard shortcuts

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