data

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2023 License: MPL-2.0 Imports: 7 Imported by: 2

Documentation

Overview

Package data provides common data types for use with the employees service.

Index

Constants

View Source
const (
	PathChangeId       string = "change_id"
	PathRegistrationId string = "registration_id"
)
View Source
const (
	ParameterChangeIds     string = "change_ids"
	ParameterDataIds       string = "data_ids"
	ParameterTypes         string = "types"
	ParameterActions       string = "actions"
	ParameterServiceNames  string = "service_names"
	ParameterLatestVersion string = "latest_version"
	ParameterSince         string = "since"
)
View Source
const (
	MethodChangeUpsert                  = http.MethodPatch
	MethodChangeRead                    = http.MethodGet
	MethodChangeDelete                  = http.MethodDelete
	MethodChangeRegister                = http.MethodPut
	MethodRegistrationChangeAcknowledge = http.MethodPut
	MethodRegistrationUpsert            = http.MethodPatch
	MethodRegistrationDelete            = http.MethodDelete
)
View Source
const (
	RouteChanges                                  string = "/api/v1/changes"
	RouteChangesWebsocket                         string = RouteChanges + "/ws"
	RouteChangesSearch                            string = RouteChanges + "/search"
	RouteChangesParam                             string = RouteChanges + "/{" + PathChangeId + "}"
	RouteChangesParamf                            string = RouteChanges + "/%s"
	RouteChangesRegistration                      string = RouteChanges + "/registration"
	RouteChangesRegistrationParam                 string = RouteChangesRegistration + "/{" + PathRegistrationId + "}"
	RouteChangesRegistrationParamf                string = RouteChangesRegistration + "/%s"
	RouteChangesRegistrationParamChanges          string = RouteChangesRegistrationParam + "/changes"
	RouteChangesRegistrationParamChangesf         string = RouteChangesRegistrationParamf + "/changes"
	RouteChangesRegistrationServiceIdAcknowledge  string = RouteChangesRegistration + "/{" + PathRegistrationId + "}/acknowledge"
	RouteChangesRegistrationServiceIdAcknowledgef string = RouteChangesRegistration + "/%s/acknowledge"
)

Variables

This section is empty.

Functions

func FromWrapper

func FromWrapper(wrapper *Wrapper) (interface{}, error)

Types

type Change

type Change struct {
	// The ID of the unique change that has occurred (v4 UUID)
	// example: 86fa2f09-d260-11ec-bd5d-0242c0a8e002
	Id string `json:"id"`

	// The time the change occurred
	// example: 1652417242000
	WhenChanged int64 `json:"when_changed,string"`

	// Identifies the someone that performed the change
	// example: bludgeon_employee_memory
	ChangedBy string `json:"changed_by"`

	// The ID of the underlying data that has been changed (v4 UUID)
	// example: 86fa2f09-d260-11ec-bd5d-0242c0a8e002
	DataId string `json:"data_id"`

	// A string that identifies the service that the change belongs to
	// example: employees
	DataServiceName string `json:"data_service_name"`

	// A string that identifies the data type that was changed
	// example: employee
	DataType string `json:"data_type"`

	//A string that identifies the action that has occured to the data
	// example: create
	DataAction string `json:"data_action"`

	// An integer that's atomically incremented each time something is mutated
	// example: 1
	DataVersion int `json:"data_version"`
}

func (*Change) MarshalBinary

func (c *Change) MarshalBinary() ([]byte, error)

func (*Change) Type

func (c *Change) Type() MessageType

func (*Change) UnmarshalBinary

func (c *Change) UnmarshalBinary(bytes []byte) error

type ChangeDigest

type ChangeDigest struct {
	Changes []*Change `json:"changes"`
}

func (*ChangeDigest) MarshalBinary

func (c *ChangeDigest) MarshalBinary() ([]byte, error)

func (*ChangeDigest) Type

func (c *ChangeDigest) Type() MessageType

func (*ChangeDigest) UnmarshalBinary

func (c *ChangeDigest) UnmarshalBinary(bytes []byte) error

type ChangePartial

type ChangePartial struct {
	// The time the change occurred
	// example: 1652417242000
	WhenChanged *int64 `json:"when_changed,string,omitempty"`

	// Identifies the someone that performed the change
	// example: bludgeon_employee_memory
	ChangedBy *string `json:"changed_by,omitempty"`

	// The ID of the underlying data that has been changed (v4 UUID)
	// example: 86fa2f09-d260-11ec-bd5d-0242c0a8e002
	DataId *string `json:"data_id,omitempty"`

	// A string that identifies the service that the change belongs to
	// example: employees
	DataServiceName *string `json:"data_service_name,omitempty"`

	// A string that identifies the data type that was changed
	// example: employee
	DataType *string `json:"data_type,omitempty"`

	//A string that identifies the action that has occured to the data
	// example: create
	DataAction *string `json:"data_action,omitempty"`

	// An integer that's atomically incremented each time something is mutated
	// example: 1
	DataVersion *int `json:"data_version,omitempty"`
}

func (*ChangePartial) MarshalBinary added in v1.1.0

func (c *ChangePartial) MarshalBinary() ([]byte, error)

func (*ChangePartial) Type added in v1.1.0

func (c *ChangePartial) Type() MessageType

func (*ChangePartial) UnmarshalBinary added in v1.1.0

func (c *ChangePartial) UnmarshalBinary(bytes []byte) error

type ChangeSearch

type ChangeSearch struct {
	ChangeIds     []string `json:"change_ids,omitempty"`
	DataIds       []string `json:"data_ids,omitempty"`
	Types         []string `json:"types,omitempty"`
	Actions       []string `json:"actions,omitempty"`
	ServiceNames  []string `json:"service_names,omitempty"`
	LatestVersion *bool    `json:"latest_version,omitempty"`
	Since         *int64   `json:"since,string,omitempty"`
}

func (*ChangeSearch) FromParams

func (c *ChangeSearch) FromParams(params map[string][]string)

func (*ChangeSearch) ToParams

func (c *ChangeSearch) ToParams() string

type Empty

type Empty struct{}

func (*Empty) MarshalBinary

func (e *Empty) MarshalBinary() ([]byte, error)

func (*Empty) Type

func (e *Empty) Type() MessageType

type MessageType

type MessageType string
const (
	MessageTypeEmpty               MessageType = "empty"
	MessageTypeChange              MessageType = "change"
	MessageTypeChangePartial       MessageType = "change_partial"
	MessageTypeChangeDigest        MessageType = "change_digest"
	MessageTypeRequestRegister     MessageType = "request_register"
	MessageTypeRequestAcknowledge  MessageType = "request_acknowledge"
	MessageTypeResponseRegister    MessageType = "response_register"
	MessageTypeResponseAcknowledge MessageType = "response_acknowledge"
)

type RequestAcknowledge

type RequestAcknowledge struct {
	ChangeIds []string `json:"change_ids"`
}

func (*RequestAcknowledge) MarshalBinary

func (r *RequestAcknowledge) MarshalBinary() ([]byte, error)

func (*RequestAcknowledge) Type

func (r *RequestAcknowledge) Type() MessageType

func (*RequestAcknowledge) UnmarshalBinary

func (r *RequestAcknowledge) UnmarshalBinary(bytes []byte) error

type RequestRegister

type RequestRegister struct {
	RegistrationId string `json:"registration_id"`
}

func (*RequestRegister) MarshalBinary

func (r *RequestRegister) MarshalBinary() ([]byte, error)

func (*RequestRegister) Type

func (r *RequestRegister) Type() MessageType

func (*RequestRegister) UnmarshalBinary

func (r *RequestRegister) UnmarshalBinary(bytes []byte) error

type ResponseAcknowledge

type ResponseAcknowledge struct {
	RegistrationId string   `json:"registration_id"`
	ChangeIds      []string `json:"change_ids"`
}

func (*ResponseAcknowledge) MarshalBinary

func (r *ResponseAcknowledge) MarshalBinary() ([]byte, error)

func (*ResponseAcknowledge) Type

func (r *ResponseAcknowledge) Type() MessageType

func (*ResponseAcknowledge) UnmarshalBinary

func (r *ResponseAcknowledge) UnmarshalBinary(bytes []byte) error

type ResponseRegister

type ResponseRegister struct {
	RegistrationId string `json:"registration_id"`
}

func (*ResponseRegister) MarshalBinary

func (r *ResponseRegister) MarshalBinary() ([]byte, error)

func (*ResponseRegister) Type

func (r *ResponseRegister) Type() MessageType

func (*ResponseRegister) UnmarshalBinary

func (r *ResponseRegister) UnmarshalBinary(bytes []byte) error

type Wrappable

type Wrappable interface {
	Type() MessageType
	encoding.BinaryMarshaler
}

type Wrapper

type Wrapper struct {
	Type  MessageType `json:"type"`
	Bytes []byte      `json:"bytes"`
}

func ToWrapper

func ToWrapper(message Wrappable) *Wrapper

func (*Wrapper) MarshalBinary

func (w *Wrapper) MarshalBinary() ([]byte, error)

Jump to

Keyboard shortcuts

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