mock

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultResponse = "default"

Variables

This section is empty.

Functions

func ToRequest

func ToRequest(server string, endPoint *EndPoint) *action.Request

Types

type Argument

type Argument struct {
	Status bool   `json:"status"`
	Key    string `json:"key"`
	Value  string `json:"value"`
}

type Body

type Body struct {
	ContentType domain.ContentType `json:"content_type"`
	Payload     string             `json:"payload"`
}

type EndPoint

type EndPoint struct {
	Id        string            `json:"_id"`
	Status    bool              `json:"status"`
	Order     int               `json:"order"`
	Timestamp int64             `json:"timestamp"`
	Modified  int64             `json:"modified"`
	Name      string            `json:"name"`
	Method    domain.HttpMethod `json:"method"`
	Path      string            `json:"path"`
	Responses []Response        `json:"responses"`
	Safe      bool              `json:"safe"`
	Owner     string            `json:"owner"`
}

func CleanEndPoint

func CleanEndPoint(owner string, endPoint *EndPoint) *EndPoint

func FixEndPoint

func FixEndPoint(owner string, endPoint *EndPoint) *EndPoint

func FixEndPoints

func FixEndPoints(owner string, endPoints []EndPoint) []EndPoint

func ToEndPointFromFull

func ToEndPointFromFull(endPoint *EndPointFull) (*EndPoint, []error)

func (EndPoint) DefaultResponse

func (r EndPoint) DefaultResponse() Response

func (EndPoint) PersistenceId

func (r EndPoint) PersistenceId() string

type EndPointFull

type EndPointFull struct {
	Id        string            `json:"_id"`
	Status    bool              `json:"status"`
	Order     int               `json:"order"`
	Timestamp int64             `json:"timestamp"`
	Modified  int64             `json:"modified"`
	Name      string            `json:"name"`
	Method    domain.HttpMethod `json:"method"`
	Path      string            `json:"path"`
	Responses []ResponseFull    `json:"responses"`
	Safe      bool              `json:"safe"`
	Owner     string            `json:"owner"`
}

func FullFromEndPoint

func FullFromEndPoint(endPoint *EndPoint) (*EndPointFull, []error)

type EndPointLite

type EndPointLite struct {
	Id        string            `json:"_id"`
	Status    bool              `json:"status"`
	Order     int               `json:"order"`
	Timestamp int64             `json:"timestamp"`
	Modified  int64             `json:"modified"`
	Name      string            `json:"name"`
	Method    domain.HttpMethod `json:"method"`
	Path      string            `json:"path"`
	Responses []string          `json:"responses"`
	Safe      bool              `json:"safe"`
	Owner     string            `json:"owner"`
}

func LiteFromEndPoint

func LiteFromEndPoint(endPoint *EndPoint) *EndPointLite

type Metrics

type Metrics struct {
	EndPoint       string            `json:"end_point"`
	Timestamp      int64             `json:"timestamp"`
	Modified       int64             `json:"modified"`
	TotalUptime    int64             `json:"total_uptime"`
	LastStarted    int64             `json:"last_started"`
	TotalRequests  int64             `json:"total_requests"`
	CountResponses map[string]uint64 `json:"count_responses"`
	MinLatency     int64             `json:"min_latency"`
	MaxLatency     int64             `json:"max_latency"`
	AvgLatency     float64           `json:"avg_latency"`
}

func EmptyMetrics

func EmptyMetrics(endPoint *EndPoint) *Metrics

func (Metrics) PersistenceId

func (r Metrics) PersistenceId() string

type RepositoryEndPoint

type RepositoryEndPoint interface {
	FindAll(owner string) []EndPoint
	FindMany(ids ...string) []EndPoint
	Find(id string) (*EndPoint, bool)
	FindByRequest(owner string, method domain.HttpMethod, path string) (*EndPoint, bool)
	Insert(endPoint *EndPoint) *EndPoint
	InsertMany(endPoint ...EndPoint) []EndPoint
	Delete(endPoint *EndPoint) *EndPoint
}

type RepositoryMetrics

type RepositoryMetrics interface {
	Find(endPoint *EndPoint) (*Metrics, bool)
	Resolve(endPoint *EndPoint, metrics *Metrics) *Metrics
	Delete(endPoint *EndPoint, metrics *Metrics) *Metrics
}

type Response

type Response struct {
	Order     int        `json:"order"`
	Status    bool       `json:"status"`
	Code      int        `json:"code"`
	Timestamp int64      `json:"timestamp"`
	Condition string     `json:"condition"`
	Name      string     `json:"name"`
	Arguments []Argument `json:"arguments"`
	Body      Body       `json:"body"`
}

func FindResponse

func FindResponse(payload string, arguments map[string]string, endPoint *EndPoint) (*Response, bool)

func FixResponses

func FixResponses(responses []Response) []Response

func ToResponse

func ToResponse(response ResponseFull) *Response

func ToResponseWithOptions

func ToResponseWithOptions(response ResponseFull, opts swr.MarshalOpts) (*Response, []error)

type ResponseFull

type ResponseFull struct {
	Order     int        `json:"order"`
	Status    bool       `json:"status"`
	Code      int        `json:"code"`
	Timestamp int64      `json:"timestamp"`
	Condition []swr.Step `json:"condition"`
	Name      string     `json:"name"`
	Arguments []Argument `json:"arguments"`
	Body      Body       `json:"body"`
}

func FromResponse

func FromResponse(response Response) *ResponseFull

func FromResponseWithOptions

func FromResponseWithOptions(response Response, opts swr.UnmarshalOpts) (*ResponseFull, []error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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