publish

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldData              = "data"
	FieldEventId           = "event-id"
	FieldEventTime         = "event-time"
	FieldEventType         = "event-type"
	FieldEventTypeVersion  = "event-type-version"
	FieldSource            = "source"
	FieldSourceType        = "source.source-type"
	FieldSourceNamespace   = "source.source-namespace"
	FieldSourceEnvironment = "source.source-environment"
	FieldTraceContext      = "trace-context"

	//AllowedIDChars
	AllowedIdChars      = `^[a-zA-Z0-9_\-]+$`
	AllowedEventIDChars = `^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$`

	// fully-qualified topic name components
	AllowedSourceEnvironmentChars = `^[a-zA-Z]+([_\-\.]?[a-zA-Z0-9]+)*$`
	AllowedSourceNamespaceChars   = `^[a-zA-Z]+([_\-\.]?[a-zA-Z0-9]+)*$`
	AllowedSourceTypeChars        = `^[a-zA-Z]+([_\-\.]?[a-zA-Z0-9]+)*$`
	AllowedEventTypeChars         = `^[a-zA-Z]+([_\-\.]?[a-zA-Z0-9]+)*$`
	AllowedEventTypeVersionChars  = `^[a-zA-Z0-9]+$`
)
View Source
const (
	/*ErrorTypeBadPayload The request payload has incorrect syntax according to the sent Content-Type.
	Check the payload content for syntax errors, such as missing commas or quotation marks that are not closed.
	*/
	ErrorTypeBadPayload = "bad_payload_syntax"
	/*ErrorTypeValidationViolation Top level validation error.
	 */
	ErrorTypeValidationViolation = "validation_violation"
	/*ErrorTypeMissingField Sub-level error type of `ErrorTypeValidationViolation` representaing that the requested body
	payload for a POST or PUT operation is missing,	which violates the defined validation constraints. This denotes
	a missing field when a value is expected.
	*/
	ErrorTypeMissingField = "missing_field"
	/*ErrorTypeInvalidField Sub-level error type of `ErrorTypeValidationViolation` representaing that the requested body
	payload for the POST or PUT operation violates the validation constraints.
	This denotes specifically that there is:
	- A type incompatibility, such as a field modeled to be an integer, but a non-numeric expression was found instead.
	- A range under or over flow validation violation cause.
	*/
	ErrorTypeInvalidField = "invalid_field"
	// ErrorTypeInternalServerError Some unexpected internal error occurred while processing the request.
	ErrorTypeInternalServerError = "internal_server_error"
	// ErrorMessageInternalServerError represents the error message for `ErrorTypeInternalServerError`
	ErrorMessageInternalServerError = "Some unexpected internal error occurred, please contact support."
	/*ErrorTypeBadRequest A generic error for bad requests sent by the clients. Use when none of the specific
	error types apply.
	*/
	ErrorTypeBadRequest = "bad_request"
	// ErrorMessageBadRequest represents the error message for `ErrorTypeBadRequest`
	ErrorMessageBadRequest = "Some unexpected internal error occurred, please contact support."
	// ErrorMessageBadPayload represents the error message for `ErrorTypeBadPayload`
	ErrorMessageBadPayload = "Something went very wrong. Please try again."
	// ErrorMessageMissingField represents the error message for `ErrorTypeMissingField`
	ErrorMessageMissingField = "We need all required fields complete to keep you moving."
	// ErrorMessageInvalidField represents the error message for `ErrorTypeInvalidField`
	ErrorMessageInvalidField = "We need all your entries to be correct to keep you moving."
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AnyValue

type AnyValue interface{}

AnyValue implements the service definition of AnyValue

type CloudEvent

type CloudEvent struct {
	PublishRequest
	Extensions Extensions `json:"extensions,omitempty"`
}

CloudEvent represents the event to be persisted to NATS

type Error

type Error struct {
	Status   int           `json:"status"`
	Type     string        `json:"type"`
	Message  string        `json:"message"`
	MoreInfo string        `json:"moreInfo"`
	Details  []ErrorDetail `json:"details"`
}

Error represents API error response code

func ErrorResponseBadPayload

func ErrorResponseBadPayload() (response *Error)

func ErrorResponseBadRequest

func ErrorResponseBadRequest() (response *Error)

func ErrorResponseEmptyRequest

func ErrorResponseEmptyRequest() (response *Error)

func ErrorResponseInternalServer

func ErrorResponseInternalServer() (response *Error)

TODO Add propper comments

func ErrorResponseMissingFieldData

func ErrorResponseMissingFieldData() (response *Error)

func ErrorResponseMissingFieldEventTime

func ErrorResponseMissingFieldEventTime() (response *Error)

func ErrorResponseMissingFieldEventType

func ErrorResponseMissingFieldEventType() (response *Error)

func ErrorResponseMissingFieldEventTypeVersion

func ErrorResponseMissingFieldEventTypeVersion() (response *Error)

func ErrorResponseMissingFieldSource

func ErrorResponseMissingFieldSource() (response *Error)

func ErrorResponseMissingFieldSourceEnvironment

func ErrorResponseMissingFieldSourceEnvironment() (response *Error)

func ErrorResponseMissingFieldSourceNamespace

func ErrorResponseMissingFieldSourceNamespace() (response *Error)

func ErrorResponseMissingFieldSourceType

func ErrorResponseMissingFieldSourceType() (response *Error)

func ErrorResponseWrongEventId

func ErrorResponseWrongEventId() (response *Error)

func ErrorResponseWrongEventTime

func ErrorResponseWrongEventTime(err error) (response *Error)

func ErrorResponseWrongEventType

func ErrorResponseWrongEventType() (response *Error)

func ErrorResponseWrongEventTypeVersion

func ErrorResponseWrongEventTypeVersion() (response *Error)

func ErrorResponseWrongSourceEnvironment

func ErrorResponseWrongSourceEnvironment() (response *Error)

func ErrorResponseWrongSourceNamespace

func ErrorResponseWrongSourceNamespace() (response *Error)

func ErrorResponseWrongSourceType

func ErrorResponseWrongSourceType() (response *Error)

func ValidatePublish

func ValidatePublish(r *PublishRequest) *Error

ValidatePublish validates a publish POST request

type ErrorDetail

type ErrorDetail struct {
	Field    string `json:"field"`
	Type     string `json:"type"`
	Message  string `json:"message"`
	MoreInfo string `json:"moreInfo"`
}

ErrorDetail represents error cause

type EventSource

type EventSource struct {
	SourceNamespace   string `json:"source-namespace"`
	SourceType        string `json:"source-type"`
	SourceEnvironment string `json:"source-environment"`
}

EventSource describes the software instance that emits the event at runtime (i.e. the producer).

type Extensions

type Extensions = map[string]interface{}

type PublishRequest

type PublishRequest struct {
	Source           *EventSource `json:"source"`
	EventType        string       `json:"event-type"`
	EventTypeVersion string       `json:"event-type-version"`
	EventID          string       `json:"event-id"`
	EventTime        string       `json:"event-time"`
	Data             AnyValue     `json:"data"`
}

PublishRequest represents a publish request

type PublishResponse

type PublishResponse struct {
	EventID string `json:"event-id"`
}

PublishResponse represents a successful publish response

type TraceContext

type TraceContext map[string]string

Jump to

Keyboard shortcuts

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