app

package
v0.0.0-...-b2c82e1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterHandlers

func RegisterHandlers(r *echo.Group, s Service, logger log.Logger)

RegisterHandlers sets up the routing of the HTTP handlers.

Types

type App

type App struct {
	entity.App
}

App represents the data about an app.

type CreateAppRequest

type CreateAppRequest struct {
	ID             string `json:"id"`
	Secret         string `json:"secret"`
	Name           string `json:"name"`
	Env            string `json:"env"`
	Callback       string `json:"callback"`
	CallbackSecret string `json:"callback_secret"`
}

func (CreateAppRequest) Validate

func (m CreateAppRequest) Validate() *response.Error

Validate validates the CreateAppRequest fields.

type ExtApp

type ExtApp struct {
	ID       string `json:"id"`
	Name     string `json:"name,omitempty"`
	Env      string `json:"env,omitempty"`
	Status   string `json:"status,omitempty"`
	Callback string `json:"callback,,omitempty"`
}

type ExtListResponse

type ExtListResponse struct {
	Page       int      `json:"page"`
	PerPage    int      `json:"per_page"`
	PageCount  int      `json:"page_count"`
	TotalCount int      `json:"total_count"`
	Items      []ExtApp `json:"items"`
}

type FactService

type FactService interface {
	Request(*fact.FactRequest) (*fact.FactResponse, error)
}

FactService service to manage sending and receiving fact requests

type Repository

type Repository interface {
	// Get returns the app with the specified app ID.
	Get(ctx context.Context, appID string) (entity.App, error)
	// Count returns the number of apps.
	Count(ctx context.Context) (int, error)
	// Create saves a new app in the storage.
	Create(ctx context.Context, app entity.App) error
	// Update updates the app with given ID in the storage.
	Update(ctx context.Context, app entity.App) error
	// Delete removes the app with given ID from the storage.
	Delete(ctx context.Context, id string) error
	// List returns a list of all entity.App
	List(ctx context.Context) ([]entity.App, error)
	// SetStatus sets the given status for a given app id.
	SetStatus(ctx context.Context, id, status string) error
	// ListByStatus returns a list of entity.App matching the given list of status
	ListByStatus(ctx context.Context, statuses []string) ([]entity.App, error)
}

Repository encapsulates the logic to access apps from the data source.

func NewRepository

func NewRepository(db *dbcontext.DB, logger log.Logger) Repository

NewRepository creates a new app repository

type Service

type Service interface {
	List(ctx context.Context) []entity.App
	ListByStatus(ctx context.Context, statuses []string) ([]entity.App, error)
	Get(ctx context.Context, id string) (App, error)
	Create(ctx context.Context, input CreateAppRequest) (App, error)
	Update(ctx context.Context, id string, input UpdateAppRequest) (App, error)
	Delete(ctx context.Context, id string) (App, error)
}

Service encapsulates usecase logic for apps.

func NewService

func NewService(repo Repository, runner self.Runner, logger log.Logger) Service

NewService creates a new app service.

type UpdateAppRequest

type UpdateAppRequest struct {
	Callback       string `json:"callback"`
	CallbackSecret string `json:"callback_secret"`
}

func (UpdateAppRequest) Validate

func (m UpdateAppRequest) Validate() *response.Error

Validate validates the CreateAppRequest fields.

Jump to

Keyboard shortcuts

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