incident

package
v0.0.0-...-dc9cd6f Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Router

func Router(incidentService Service, router *gin.RouterGroup)

Router creates a new Controller and add all available endpoints to a Gin RouterGroup

Types

type Controller

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

Controller contains all the available handlers

func NewIncidentController

func NewIncidentController(service Service) *Controller

NewIncidentController creates a new Controller

func (*Controller) Create

func (ctrl *Controller) Create(c *gin.Context)

Create it's the handler function for Component creation endpoints

func (*Controller) Find

func (ctrl *Controller) Find(c *gin.Context)

Find it's the handler function for filtered Component retrieve endpoints

func (*Controller) List

func (ctrl *Controller) List(c *gin.Context)

List it's the handler function for Incident listing endpoints

type Read

type Read interface {
	Find(query map[string]interface{}) ([]models.Incident, error)
	FindOne(query map[string]interface{}) (models.Incident, error)
	List(startDt time.Time, endDt time.Time, unresolved bool) ([]models.Incident, error)
}

Read implements the read action methods

type Repository

type Repository interface {
	Read
	Write
}

Repository describes the repository where the data will be written and read from

func NewMongoRepository

func NewMongoRepository(session *mgo.Session) Repository

NewMongoRepository creates a new Repository implementation using the MongoDB as database

type Service

type Service interface {
	CreateIncidents(incident models.Incident) error
	UpdateIncident(incident models.Incident) error
	FindIncidents(query map[string]interface{}) ([]models.Incident, error)
	ListIncidents(queryParameters models.ListIncidentQueryParameters) ([]models.Incident, error)
	ValidateDate(startDate time.Time, endDate time.Time) error
}

Service describes the use case

func NewService

func NewService(r Repository, component component.Service, l logs.Log) Service

NewService creates implementation of the Service interface

type Write

type Write interface {
	Insert(incident models.Incident) error
	Update(incident models.Incident) error
}

Write implements the write action methods

Jump to

Keyboard shortcuts

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