Documentation ¶
Index ¶
- Variables
- func ExtractEtagTypeVersion(etag string) string
- func GetEnv(ctx context.Context, env string, defaultValue string) string
- func VerifyOrCreateID(correlationID string) string
- type BodyCategory
- type CodeableConcept
- type Coding
- type ConsumeAndProcess
- func (consumeAndProcess *ConsumeAndProcess) GetInterceptors() []EventConsumerInterceptor
- func (consumeAndProcess *ConsumeAndProcess) Run(ctx context.Context, sigs chan os.Signal, wg *sync.WaitGroup)
- func (consumeAndProcess *ConsumeAndProcess) SetInterceptors(interceptors ...EventConsumerInterceptor)
- type EventConsumer
- type EventConsumerInterceptor
- type EventConsumerInterceptorAdaptor
- func (eventConsumerInterceptorAdaptor EventConsumerInterceptorAdaptor) HandleError(consumedTopic Topic, receivedMessage Message, err error) bool
- func (eventConsumerInterceptorAdaptor EventConsumerInterceptorAdaptor) IncomingMessagePostProcessMessage(consumedTopic Topic, receivedMessage Message) bool
- func (eventConsumerInterceptorAdaptor EventConsumerInterceptorAdaptor) IncomingMessagePreParsing(consumedTopic Topic, receivedMessage Message) bool
- func (eventConsumerInterceptorAdaptor EventConsumerInterceptorAdaptor) IncomingMessagePreProcessMessage(consumedTopic Topic, receivedMessage Message) bool
- func (eventConsumerInterceptorAdaptor EventConsumerInterceptorAdaptor) ProcessingCompletedNormally(consumedTopic Topic, receivedMessage Message)
- type EventProcessor
- type EventProducer
- type Header
- type Message
- func (m *Message) CloneFields(message Message) error
- func (m *Message) GetBody() string
- func (m *Message) GetBodyCategory() BodyCategory
- func (m *Message) GetBodyType() string
- func (m *Message) GetContentVersion() string
- func (m *Message) GetCorrelationID() string
- func (m *Message) GetEtag() string
- func (m *Message) GetEtagVersion() string
- func (m *Message) GetHeaderVersion() Version
- func (m *Message) GetIfMatch() string
- func (m *Message) GetIfMatchVersion() string
- func (m *Message) GetIfNoneExist() string
- func (m *Message) GetLocation() string
- func (m *Message) GetPrefer() Prefer
- func (m *Message) GetSecurity() string
- func (m *Message) GetSender() string
- func (m *Message) GetSession() string
- func (m *Message) GetTransactionID() string
- func (m *Message) SetBody(body string) *Message
- func (m *Message) SetBodyCategory(bodyCategory BodyCategory) *Message
- func (m *Message) SetBodyType(bodyType string) *Message
- func (m *Message) SetContentVersion(contentVersion string) *Message
- func (m *Message) SetCorrelationID(correlationID string) *Message
- func (m *Message) SetEtag(etag string) *Message
- func (m *Message) SetHeaderVersion(version Version) *Message
- func (m *Message) SetIfMatch(ifMatch string) *Message
- func (m *Message) SetIfNoneExist(ifNoneExist string) *Message
- func (m *Message) SetLocation(location string) *Message
- func (m *Message) SetPrefer(prefer Prefer) *Message
- func (m *Message) SetSecurity(security string) *Message
- func (m *Message) SetSender(sender string) *Message
- func (m *Message) SetSession(session string) *Message
- func (m *Message) SetTransactionID(transactionID string) *Message
- func (m *Message) SetWeakEtagVersion(etag string) *Message
- func (m *Message) SetWeakIfMatchVersion(ifMatch string) *Message
- func (m *Message) ToByteArray() []byte
- type Operation
- type OperationOutcome
- func (ou *OperationOutcome) GetCode() string
- func (ou *OperationOutcome) GetDiagnostics() string
- func (ou *OperationOutcome) GetSeverity() string
- func (ou *OperationOutcome) SetCode(code string) *OperationOutcome
- func (ou *OperationOutcome) SetDiagnostics(diagnostics string) *OperationOutcome
- func (ou *OperationOutcome) SetSeverity(severity string) *OperationOutcome
- type OperationOutcomeIssue
- type Prefer
- type Topic
- func (t *Topic) AddDataCode(dataCode string) *Topic
- func (t *Topic) Equals(other Topic) bool
- func (t *Topic) GetDataCategory() BodyCategory
- func (t *Topic) GetDataCodes() []string
- func (t *Topic) GetDataType() string
- func (t *Topic) GetOperation() Operation
- func (t *Topic) SetDataCategory(dataCategory BodyCategory) *Topic
- func (t *Topic) SetDataCodes(dataCodes []string) *Topic
- func (t *Topic) SetDataType(dataType string) *Topic
- func (t *Topic) SetOperation(operation Operation) *Topic
- func (t *Topic) String() string
- type Topics
- type Version
Constants ¶
This section is empty.
Variables ¶
var TopicSeparator = "_"
TopicSeparator is the string used to separate parts of a topic
var VERSION = NewVersion("3.0.0")
VERSION is the current version of the message format Change this whenever you make changes to the Message format! Uses semantic versioning
Functions ¶
func ExtractEtagTypeVersion ¶
ExtractEtagTypeVersion is a method...
func VerifyOrCreateID ¶
VerifyOrCreateID checks if a correlationID exists and fits with the scheme of correlationId's used in this library. if it does, it returns the correlationID, if it doesn't it either adjusts it or generates a new one, and returns that ported from the method used in https://bitbucket.org/4s/messaging/src/master/src/main/java/dk/s4/microservices/messaging/MessagingUtils.java
Types ¶
type BodyCategory ¶
type BodyCategory int
BodyCategory is an enum for the set of valid message bodyCategories.
const ( FHIR BodyCategory = iota + 1 CDA System )
The valid bodyCategory values
func BodyCategoryFromString ¶
func BodyCategoryFromString(catString string) (BodyCategory, error)
BodyCategoryFromString parses a string into a BodyCategory
func (BodyCategory) MarshalJSON ¶
func (b BodyCategory) MarshalJSON() ([]byte, error)
MarshalJSON marshals BodyCategory as a quoted json string
func (BodyCategory) String ¶
func (b BodyCategory) String() string
func (*BodyCategory) UnmarshalJSON ¶
func (b *BodyCategory) UnmarshalJSON(byteArray []byte) error
UnmarshalJSON unmashals a quoted json string to BodyCategory
type CodeableConcept ¶
type CodeableConcept struct { Coding []Coding `json:"coding,omitempty"` Text string `json:"text,omitempty"` }
CodeableConcept represents a value that is usually supplied by providing a reference to one or more terminologies or ontologies but may also be defined by the provision of text.
type Coding ¶
type Coding struct { System string `json:"system,omitempty"` Version string `json:"version,omitempty"` Code string `json:"code,omitempty"` Display string `json:"display,omitempty"` UserSelected bool `json:"userSelected,omitempty"` }
Coding is a representation of a defined concept using a symbol from a defined "code system"
type ConsumeAndProcess ¶
type ConsumeAndProcess struct {
// contains filtered or unexported fields
}
ConsumeAndProcess is a struct for consuming, processing and responding to messages over kafka
func NewConsumeAndProcess ¶
func NewConsumeAndProcess( ctx context.Context, consumer EventConsumer, producer EventProducer, ) (ConsumeAndProcess, error)
NewConsumeAndProcess functions as a constructor that returns a new instance of ConsumeAndProcess
func (*ConsumeAndProcess) GetInterceptors ¶
func (consumeAndProcess *ConsumeAndProcess) GetInterceptors() []EventConsumerInterceptor
GetInterceptors returns a list of all registered server interceptors
func (*ConsumeAndProcess) Run ¶
func (consumeAndProcess *ConsumeAndProcess) Run( ctx context.Context, sigs chan os.Signal, wg *sync.WaitGroup, )
Run is a method that runs the consumeAndProcess method in a loop until it is stopped This method should be run in a dedicated goroutine
func (*ConsumeAndProcess) SetInterceptors ¶
func (consumeAndProcess *ConsumeAndProcess) SetInterceptors(interceptors ...EventConsumerInterceptor)
SetInterceptors sets (or clears) the list of interceptors
type EventConsumer ¶
type EventConsumer interface { SubscribeTopics(topics Topics) error SubscribeTopicPattern(regexp *regexp.Regexp) error Poll(ctx context.Context) (Message, Topic, error) ProcessMessage(ctx context.Context, consumedTopic Topic, receivedMessage Message, messageProcessedTopic *Topic, outgoingMessage *Message) error Commit() error SetPreParseHook(func(topic Topic, message Message) bool) SetPreProcessHook(func(topic Topic, message Message) bool) SetPostProcessHook(func(topic Topic, message Message) bool) Close() }
EventConsumer is an interface for event consumers
type EventConsumerInterceptor ¶
type EventConsumerInterceptor interface { // IncomingMessagePreParsing is called before any other processing takes place for each incoming message. It may be e.g. be used // to provide alternate processing of incoming messages. IncomingMessagePreParsing(consumedTopic Topic, receivedMessage Message) bool // IncomingMessagePreProcessMessage is called for each message, immediately after parsing of incoming topic and message strings and // before any other processing takes place for each incoming message. It may e.g. be used to provide alternate processing of incoming messages. IncomingMessagePreProcessMessage(consumedTopic Topic, receivedMessage Message) bool // IncomingMessagePostProcessMessage is called for each message, immediately after processing the incoming message, but before any // response is sent out be the {@link EventConsumer}. It may e.g. be used to provide alternate responses to incoming messages. IncomingMessagePostProcessMessage(consumedTopic Topic, receivedMessage Message) bool // HandleError is called upon any exception being thrown within the {@link EventConsumer's} processing code. // This includes parse exceptions and message incompatibility exceptions. HandleError(consumedTopic Topic, receivedMessage Message, err error) bool // ProcessingCompletedNormally is called after all processing of an incoming message is completed, but only if the // request completes normally (i.e. no exception is thrown). ProcessingCompletedNormally(consumedTopic Topic, receivedMessage Message) }
EventConsumerInterceptor is a ... TODO:
type EventConsumerInterceptorAdaptor ¶
type EventConsumerInterceptorAdaptor struct{}
EventConsumerInterceptorAdaptor is a struct implementing all methods for EventConsumerInterceptor, providing a No-op implementagion of all methods, always returning true
func (EventConsumerInterceptorAdaptor) HandleError ¶
func (eventConsumerInterceptorAdaptor EventConsumerInterceptorAdaptor) HandleError(consumedTopic Topic, receivedMessage Message, err error) bool
HandleError is called upon any exception being thrown within the {@link EventConsumer's} processing code. This includes parse exceptions and message incompatibility exceptions.
func (EventConsumerInterceptorAdaptor) IncomingMessagePostProcessMessage ¶
func (eventConsumerInterceptorAdaptor EventConsumerInterceptorAdaptor) IncomingMessagePostProcessMessage(consumedTopic Topic, receivedMessage Message) bool
IncomingMessagePostProcessMessage is called for each message, immediately after processing the incoming message, but before any response is sent out be the {@link EventConsumer}. It may e.g. be used to provide alternate responses to incoming messages.
func (EventConsumerInterceptorAdaptor) IncomingMessagePreParsing ¶
func (eventConsumerInterceptorAdaptor EventConsumerInterceptorAdaptor) IncomingMessagePreParsing(consumedTopic Topic, receivedMessage Message) bool
IncomingMessagePreParsing is called before any other processing takes place for each incoming message. It may be e.g. be used to provide alternate processing of incoming messages.
func (EventConsumerInterceptorAdaptor) IncomingMessagePreProcessMessage ¶
func (eventConsumerInterceptorAdaptor EventConsumerInterceptorAdaptor) IncomingMessagePreProcessMessage(consumedTopic Topic, receivedMessage Message) bool
IncomingMessagePreProcessMessage is called for each message, immediately after parsing of incoming topic and message strings and before any other processing takes place for each incoming message. It may e.g. be used to provide alternate processing of incoming messages.
func (EventConsumerInterceptorAdaptor) ProcessingCompletedNormally ¶
func (eventConsumerInterceptorAdaptor EventConsumerInterceptorAdaptor) ProcessingCompletedNormally(consumedTopic Topic, receivedMessage Message)
ProcessingCompletedNormally is called after all processing of an incoming message is completed, but only if the request completes normally (i.e. no exception is thrown).
type EventProcessor ¶
type EventProcessor interface { ProcessMessage(ctx context.Context, consumedTopic Topic, receivedMessage Message, messageProcessedTopic *Topic, outgoingMessage *Message) error }
EventProcessor is an interface for EventProcessors
type EventProducer ¶
EventProducer is an interface for eventproducers
type Header ¶
type Header struct { HeaderVersion Version `json:"version,omitempty"` Sender string `json:"sender,omitempty"` BodyCategory BodyCategory `json:"bodyCategory,omitempty"` BodyType string `json:"bodyType,omitempty"` ContentVersion string `json:"contentVersion,omitempty"` Prefer Prefer `json:"prefer,omitempty"` Etag string `json:"etag,omitempty"` IfMatch string `json:"ifMatch,omitempty"` IfNoneExist string `json:"ifNoneExist,omitempty"` Location string `json:"location,omitempty"` CorrelationID string `json:"correlationId,omitempty"` TransactionID string `json:"transactionId,omitempty"` Security string `json:"security,omitempty"` Session string `json:"session,omitempty"` }
Header is the header of the message
type Message ¶
Message is struct for producing messages on the form:
{ "header": { "sender": "obs-input-service", "bodyCategory": "FHIR", "bodyType": "Observation", "contentVersion": "3.3.0", "location":"http://fhirtest.uhn.ca/baseDstu3/Observation/15354/_history/1" "correlationId": "xez5ZXQcDG6" "transactionId": "e6651fe2-fb8e-4a54-8b8e-7343dbdb997c" "security": ... }, "body": { "resourceType": "Observation", ... } }
func NewMessage ¶
func NewMessage() Message
NewMessage functions as a constructor for Message that returns a new instance of Message
func (*Message) CloneFields ¶
CloneFields copies the fields from the provided message, to this message.
func (*Message) GetBodyCategory ¶
func (m *Message) GetBodyCategory() BodyCategory
GetBodyCategory returns the bodyCategory of the message
func (*Message) GetBodyType ¶
GetBodyType returns the bodytype of the message
func (*Message) GetContentVersion ¶
GetContentVersion returns the content version of the message
func (*Message) GetCorrelationID ¶
GetCorrelationID returns the correlationID of the message
func (*Message) GetEtagVersion ¶
GetEtagVersion returns the version part of an E-tag. E.g. if Etag contains the weak etag 'W/"4232"' this function will return the string 4232
func (*Message) GetHeaderVersion ¶
GetHeaderVersion returns the headerVersion of the message
func (*Message) GetIfMatch ¶
GetIfMatch returns the ifMatch header of the message
func (*Message) GetIfMatchVersion ¶
GetIfMatchVersion returns the version part of an If-Match header. E.g. if If-Match contains the weak etag 'W/"4232"' this function will return the string 4232
func (*Message) GetIfNoneExist ¶
GetIfNoneExist returns the ifMatch header of the message
func (*Message) GetLocation ¶
GetLocation returns the location header of the message
func (*Message) GetSecurity ¶
GetSecurity returns the security header of the message
func (*Message) GetSession ¶
GetSession returns the session header of the message
func (*Message) GetTransactionID ¶
GetTransactionID returns the transactionID of the message
func (*Message) SetBodyCategory ¶
func (m *Message) SetBodyCategory(bodyCategory BodyCategory) *Message
SetBodyCategory sets the bodyCategory of the message
func (*Message) SetBodyType ¶
SetBodyType sets the bodytype of the message
func (*Message) SetContentVersion ¶
SetContentVersion sets the content version of the message
func (*Message) SetCorrelationID ¶
SetCorrelationID sets the correlationID of the message
func (*Message) SetHeaderVersion ¶
SetHeaderVersion sets the headerVersion of the message
func (*Message) SetIfMatch ¶
SetIfMatch sets the ifMatch header of the message
func (*Message) SetIfNoneExist ¶
SetIfNoneExist sets the ifNoneExist header of the message
func (*Message) SetLocation ¶
SetLocation sets the location header of the message
func (*Message) SetSecurity ¶
SetSecurity sets the security header of the message
func (*Message) SetSession ¶
SetSession sets the session header of the message
func (*Message) SetTransactionID ¶
SetTransactionID sets the transactionID of the message
func (*Message) SetWeakEtagVersion ¶
SetWeakEtagVersion sets the etag version formatted as a weak Etag
func (*Message) SetWeakIfMatchVersion ¶
SetWeakIfMatchVersion sets the ifMatch header formatted as a weak Etag
func (*Message) ToByteArray ¶
ToByteArray returns message as ByteArray
type Operation ¶
type Operation int
Operation is an enum for the set of valid topic Operations.
const ( // Events InputReceived Operation = iota + 1 DataValidated DataConverted DataCreated DataUpdated TransactionCompleted ProcessingFailed Error // Commands Create Update Delete )
The valid Operation values
func OperationFromString ¶
OperationFromString parses a string into an Operation
type OperationOutcome ¶
type OperationOutcome struct { ResourceType string `json:"resourceType,omitempty"` ID string `json:"id,omitempty"` Text interface{} `json:"text,omitempty"` Issue OperationOutcomeIssue `json:"issue,omitempty"` }
OperationOutcome is a collection of error, warning or information messages that result from a system action.
func NewOperationOutcome ¶
func NewOperationOutcome(severity string, code string, diagnostics string) OperationOutcome
NewOperationOutcome functions as a constructor for OperationOutcome and returns a new instance of OperationOutcome
func (*OperationOutcome) GetCode ¶
func (ou *OperationOutcome) GetCode() string
GetCode returns the Code of the OperationOutcome
func (*OperationOutcome) GetDiagnostics ¶
func (ou *OperationOutcome) GetDiagnostics() string
GetDiagnostics returns the Diagnostics of the OperationOutcome
func (*OperationOutcome) GetSeverity ¶
func (ou *OperationOutcome) GetSeverity() string
GetSeverity returns the Severity of the OperationOutcome
func (*OperationOutcome) SetCode ¶
func (ou *OperationOutcome) SetCode(code string) *OperationOutcome
SetCode sets the Code of the OperationOutcome
func (*OperationOutcome) SetDiagnostics ¶
func (ou *OperationOutcome) SetDiagnostics(diagnostics string) *OperationOutcome
SetDiagnostics sets the Diagnostics of the OperationOutcome
func (*OperationOutcome) SetSeverity ¶
func (ou *OperationOutcome) SetSeverity(severity string) *OperationOutcome
SetSeverity sets the Severity of the OperationOutcome
type OperationOutcomeIssue ¶
type OperationOutcomeIssue struct { Severity string `json:"severity,omitempty"` Code string `json:"code,omitempty"` Details CodeableConcept `json:"details,omitempty"` Diagnostics string `json:"diagnostics,omitempty"` Location string `json:"location,omitempty"` Expression string `json:"expression,omitempty"` }
OperationOutcomeIssue is a single issue associated with the action
type Prefer ¶
type Prefer int
Prefer is an enum for the set of valid message prefers.
func PreferFromString ¶
PreferFromString parses a string into a prefer
func (Prefer) MarshalJSON ¶
MarshalJSON marshals Prefer as a quoted json string
func (*Prefer) UnmarshalJSON ¶
UnmarshalJSON unmashals a quoted json string to Prefer
type Topic ¶
type Topic struct {
// contains filtered or unexported fields
}
Topic is a struct representing a Topic
func NewTopic ¶
func NewTopic() Topic
NewTopic functions as a constructor for Topic that returns a new instance of Topic
func NewTopicFromTopic ¶
NewTopicFromTopic functions as a constructor for Topic that returns a new instance of Topic based on the provided topic
func TopicFromString ¶
TopicFromString creates a topic from the provided string
func (*Topic) AddDataCode ¶
AddDataCode adds a dataCode to the topics dataCode array
func (*Topic) Equals ¶
Equals checks whether the topic upon which this method was called, is equal to the provided other topic
func (*Topic) GetDataCategory ¶
func (t *Topic) GetDataCategory() BodyCategory
GetDataCategory returns the DataCategory of the topic
func (*Topic) GetDataCodes ¶
GetDataCodes returns the DataCodes of the topic
func (*Topic) GetDataType ¶
GetDataType returns the DataType of the topic
func (*Topic) GetOperation ¶
GetOperation returns the Operation of the topic
func (*Topic) SetDataCategory ¶
func (t *Topic) SetDataCategory(dataCategory BodyCategory) *Topic
SetDataCategory sets DataCategory of Topic
func (*Topic) SetDataCodes ¶
SetDataCodes sets DataCodes of Topic
func (*Topic) SetDataType ¶
SetDataType sets DataType of Topic
func (*Topic) SetOperation ¶
SetOperation sets the Operation of the Topic
type Topics ¶
type Topics []Topic
Topics is a slice topics
func (Topics) StringArray ¶
StringArray returns the topics as an array og strings
type Version ¶
Version is an object that represents a version in semantic versioning
func NewVersion ¶
NewVersion acts as a constructor for Version and returns a new instance of version, based on the provided versionstring
func (Version) IsCompatible ¶
IsCompatible compares two versions for compatibility
func (Version) MarshalJSON ¶
MarshalJSON marshals BodyCategory as a quoted json string
func (*Version) UnmarshalJSON ¶
UnmarshalJSON unmashals a quoted json string to BodyCategory