diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3e85607 --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go workspace file +go.work +.idea/ +.DS_Store +go.sum diff --git a/README.md b/README.md index 5ed2347..6011dff 100755 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This utility provides the capability for creating pipelines that pass messages b ## Installation ``` -require github.com/puremvc/puremvc-go-util-pipes v1.0.0 +require github.com/puremvc/puremvc-go-util-pipes v1.1.0 ``` ## Platforms / Technologies @@ -18,7 +18,7 @@ require github.com/puremvc/puremvc-go-util-pipes v1.0.0 * [Windows](https://en.wikipedia.org/wiki/Microsoft_Windows) ## Status -Production - [Version 1.0](https://github.com/PureMVC/puremvc-go-util-pipes/blob/master/VERSION) +Production - [Version 1.1](https://github.com/PureMVC/puremvc-go-util-pipes/blob/master/VERSION) ## License * PureMVC Go MultiCore Utility – Pipes - Copyright © 2019 [Saad Shams](https://www.linkedin.com/in/muizz/) diff --git a/VERSION b/VERSION index b036913..6224deb 100755 --- a/VERSION +++ b/VERSION @@ -1,10 +1,12 @@ PureMVC Go MultiCore Utility - Pipes -------------------------------------------------------------------------- -Release Date: 04/25/19 +Release Date: 12/12/23 Platform: Go Version: 1 - Revision: 0 + Revision: 1 Minor: 0 Authors: Saad Shams -------------------------------------------------------------------------- 1.0 - Initial release. + +1.1 - Updated to use Go 1.21. Minor Updates. diff --git a/go.mod b/go.mod index 026dbfc..976faf2 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ module github.com/puremvc/puremvc-go-util-pipes -go 1.12 +go 1.21 -require github.com/puremvc/puremvc-go-multicore-framework v1.0.0 +require github.com/puremvc/puremvc-go-multicore-framework v1.1.0 diff --git a/go.sum b/go.sum deleted file mode 100644 index cac1252..0000000 --- a/go.sum +++ /dev/null @@ -1,2 +0,0 @@ -github.com/puremvc/puremvc-go-multicore-framework v1.0.0 h1:BW7GUsuGBXoibTuZiwibTEZXu2gWPDf73yz7bHSI4S8= -github.com/puremvc/puremvc-go-multicore-framework v1.0.0/go.mod h1:XH8nNOatK3OuCuQPWHosyFxfHoO4FmE4KT1g+GC0Xqo= diff --git a/src/interfaces/IPipeAware.go b/src/interfaces/IPipeAware.go index 32ecf12..f4b78a2 100755 --- a/src/interfaces/IPipeAware.go +++ b/src/interfaces/IPipeAware.go @@ -9,7 +9,7 @@ package interfaces /* -Pipe Aware interface. +IPipeAware Pipe Aware interface. Can be implemented by any PureMVC Core that wishes to communicate with other Cores using the Pipes diff --git a/src/interfaces/IPipeFitting.go b/src/interfaces/IPipeFitting.go index 87ad03b..4c8c015 100755 --- a/src/interfaces/IPipeFitting.go +++ b/src/interfaces/IPipeFitting.go @@ -9,20 +9,20 @@ package interfaces /* -Pipe Fitting Interface. +IPipeFitting Pipe Fitting Interface. An IPipeFitting can be connected to other IPipeFittings, forming a Pipeline. IPipeMessages are written to one end of a Pipeline by some client code. The messages are then -transfered in synchronous fashion from one fitting to the next. +transferred in synchronous fashion from one fitting to the next. */ type IPipeFitting interface { /* Connect another Pipe Fitting to the output. Fittings connect and write to - other fittings in a one way syncrhonous + other fittings in a one way synchronous chain, as water typically flows one direction through a physical pipe. @@ -38,7 +38,7 @@ type IPipeFitting interface { into a pipeline, you need to keep (at least briefly) a reference to both sides of the pipeline in order to connect them to the input and output of whatever - fiting that you're splicing in. + fitting that you're splicing in. - returns: IPipeFitting the now disconnected output fitting */ diff --git a/src/interfaces/IPipeMessage.go b/src/interfaces/IPipeMessage.go index 4d7697b..1ef002b 100755 --- a/src/interfaces/IPipeMessage.go +++ b/src/interfaces/IPipeMessage.go @@ -9,11 +9,11 @@ package interfaces /* -Pipe Message Interface. +IPipeMessage Pipe Message Interface. -IPipeMessages are objects written intoto a Pipeline, +IPipeMessages are objects written into a Pipeline, composed of IPipeFittings. The message is passed from -one fitting to the next in syncrhonous fashion. +one fitting to the next in synchronous fashion. Depending on type, messages may be handled differently by the fittings. diff --git a/src/messages/FilterControlMessage.go b/src/messages/FilterControlMessage.go index 62d1319..6d923b3 100755 --- a/src/messages/FilterControlMessage.go +++ b/src/messages/FilterControlMessage.go @@ -18,7 +18,7 @@ const ( ) /* -Filter Control Message. +FilterControlMessage Filter Control Message. A special message type for controlling the behavior of a Filter. @@ -50,49 +50,49 @@ type FilterControlMessage struct { } /* - Constructor - */ +NewFilterControlMessage Constructor +*/ func NewFilterControlMessage(_type string, name string, filter func(interfaces.IPipeMessage, interface{}) bool, params interface{}) *FilterControlMessage { return &FilterControlMessage{Message: Message{_type: _type}, name: name, filter: filter, params: params} } /* - Set the target filter name. +SetName Set the target filter name. */ func (self *FilterControlMessage) SetName(name string) { self.name = name } /* - Get the target filter name. +Name Get the target filter name. */ func (self *FilterControlMessage) Name() string { return self.name } /* - Set the filter function. +SetFilter Set the filter function. */ func (self *FilterControlMessage) SetFilter(filter func(interfaces.IPipeMessage, interface{}) bool) { self.filter = filter } /* - Get the filter function. +Filter Get the filter function. */ func (self *FilterControlMessage) Filter() func(interfaces.IPipeMessage, interface{}) bool { return self.filter } /* - Set the parameters object. +SetParams Set the parameters object. */ func (self *FilterControlMessage) SetParams(params interface{}) { self.params = params } /* - Get the parameters object. +Params Get the parameters object. */ func (self *FilterControlMessage) Params() interface{} { return self.params diff --git a/src/messages/Message.go b/src/messages/Message.go index cbd4c29..edf7cea 100755 --- a/src/messages/Message.go +++ b/src/messages/Message.go @@ -18,7 +18,7 @@ const ( ) /* -Pipe Message. +Message Pipe Message. Messages travelling through a Pipeline can be filtered, and queued. In a queue, they may @@ -35,63 +35,63 @@ type Message struct { } /* - Constructor - */ +NewMessage Constructor +*/ func NewMessage(_type string, header interface{}, body interface{}, priority int) interfaces.IPipeMessage { return &Message{_type: _type, header: header, body: body, priority: priority} } /* - Get the type of this message +Type Get the type of this message */ func (self *Message) Type() string { return self._type } /* - Set the type of this message +SetType Set the type of this message */ func (self *Message) SetType(_type string) { self._type = _type } /* - Get the priority of this message +Priority Get the priority of this message */ func (self *Message) Priority() int { return self.priority } /* - Set the priority of this message +SetPriority Set the priority of this message */ func (self *Message) SetPriority(priority int) { self.priority = priority } /* - Get the header of this message +Header Get the header of this message */ func (self *Message) Header() interface{} { return self.header } /* - Set the header of this message +SetHeader Set the header of this message */ func (self *Message) SetHeader(header interface{}) { self.header = header } /* - Get the body of this message +Body Get the body of this message */ func (self *Message) Body() interface{} { return self.body } /* - Set the body of this message +SetBody Set the body of this message */ func (self *Message) SetBody(body interface{}) { self.body = body diff --git a/src/messages/QueueControlMessage.go b/src/messages/QueueControlMessage.go index 07621bf..d933f68 100755 --- a/src/messages/QueueControlMessage.go +++ b/src/messages/QueueControlMessage.go @@ -15,7 +15,7 @@ const ( ) /* -Queue Control Message. +QueueControlMessage Queue Control Message. A special message for controlling the behavior of a Queue. @@ -32,8 +32,8 @@ type QueueControlMessage struct { } /* - Constructor - */ +NewQueueControlMessage Constructor +*/ func NewQueueControlMessage(_type string) *QueueControlMessage { return &QueueControlMessage{Message: Message{_type: _type, header: nil, body: nil, priority: PRIORITY_MED}} } diff --git a/src/plumbing/Filter.go b/src/plumbing/Filter.go index c4e0012..93772cc 100755 --- a/src/plumbing/Filter.go +++ b/src/plumbing/Filter.go @@ -14,7 +14,7 @@ import ( ) /* -Pipe Filter. +Filter Pipe Filter. Filters may modify the contents of messages before writing them to their output pipe fitting. They may also have their parameters and @@ -30,39 +30,39 @@ type Filter struct { } /* - Handle the incoming message. +Write Handle the incoming message. - If message type is normal, filter the message (unless in BYPASS mode) - and write the result to the output pipe fitting if the filter - operation is successful. +If message type is normal, filter the message (unless in BYPASS mode) +and write the result to the output pipe fitting if the filter +operation is successful. - The messages.SET_PARAMS message type tells the Filter - that the message class is FilterControlMessage, which it - casts the message to in order to retrieve the filter parameters - object if the message is addressed to this filter. +The messages.SET_PARAMS message type tells the Filter +that the message class is FilterControlMessage, which it +casts the message to in order to retrieve the filter parameters +object if the message is addressed to this filter. - The messages.SET_FILTER message type tells the Filter - that the message class is FilterControlMessage, - which it casts the message to in order to retrieve the filter function. +The messages.SET_FILTER message type tells the Filter +that the message class is FilterControlMessage, +which it casts the message to in order to retrieve the filter function. - The messages.BYPASS message type tells the Filter - that it should go into Bypass mode operation, passing all normal - messages through unfiltered. +The messages.BYPASS message type tells the Filter +that it should go into Bypass mode operation, passing all normal +messages through unfiltered. - The messages.FILTER message type tells the Filter - that it should go into Filtering mode operation, filtering all - normal normal messages before writing out. This is the default - mode of operation and so this message type need only be sent to - cancel a previous BYPASS message. +The messages.FILTER message type tells the Filter +that it should go into Filtering mode operation, filtering all +normal messages before writing out. This is the default +mode of operation and so this message type need only be sent to +cancel a previous BYPASS message. - The Filter only acts on the control message if it is targeted - to this named filter instance. Otherwise it writes through to the - output. +The Filter only acts on the control message if it is targeted +to this named filter instance. Otherwise, it writes through to the +output. - - parameter message: IPipeMessage to write on the output +- parameter message: IPipeMessage to write on the output - - returns: Boolean True if the filter process does not throw an error and subsequent operations - in the pipeline succede. +- returns: Boolean True if the filter process does not throw an error and subsequent operations +in the pipeline succeeds. */ func (self *Filter) Write(message interfaces.IPipeMessage) bool { success := true @@ -100,19 +100,19 @@ func (self *Filter) Write(message interfaces.IPipeMessage) bool { } else { success = self.Output.Write(message) } - default: // Write control messages for other fittings through + default: // Write control messages for other fittings through success = self.Output.Write(message) } return success } -// Is the message directed at this filter instance? +// IsTarget Is the message directed at this filter instance? func (self *Filter) IsTarget(message interfaces.IPipeMessage) bool { return message.(*messages.FilterControlMessage).Name() == self.Name } -// Filter the message. +// ApplyFilter Filter the message. func (self *Filter) ApplyFilter(message interfaces.IPipeMessage) bool { return self.Filter(message, self.Params) } diff --git a/src/plumbing/Junction.go b/src/plumbing/Junction.go index 2348b3d..5394ad1 100755 --- a/src/plumbing/Junction.go +++ b/src/plumbing/Junction.go @@ -19,7 +19,7 @@ const ( ) /* -Pipe Junction. +Junction Pipe Junction. Manages Pipes for a Module. @@ -34,31 +34,31 @@ You can send an IPipeMessage on a named INPUT Pipe or add a PipeListener to registered INPUT Pipe. */ type Junction struct { - inputPipes []string - outputPipes []string - PipesMap map[string]interfaces.IPipeFitting - PipesMapMutex sync.RWMutex - PipeTypesMap map[string]string + inputPipes []string + outputPipes []string + PipesMap map[string]interfaces.IPipeFitting + PipesMapMutex sync.RWMutex + PipeTypesMap map[string]string } /* - Register a pipe with the junction. +RegisterPipe Register a pipe with the junction. - Pipes are registered by unique name and type, - which must be either Junction.INPUT - or Junction.OUTPUT. +Pipes are registered by unique name and type, +which must be either Junction.INPUT +or Junction.OUTPUT. - NOTE: You cannot have an INPUT pipe and an OUTPUT - pipe registered with the same name. All pipe names - must be unique regardless of type. +NOTE: You cannot have an INPUT pipe and an OUTPUT +pipe registered with the same name. All pipe names +must be unique regardless of type. - - parameter name: name of the Pipe Fitting +- parameter name: name of the Pipe Fitting - - parameter type: input or output +- parameter type: input or output - - parameter pipe: instance of the IPipeFitting +- parameter pipe: instance of the IPipeFitting - - returns: Bool true if successfully registered. false if another pipe exists by that name. +- returns: Bool true if successfully registered. false if another pipe exists by that name. */ func (self *Junction) RegisterPipe(name string, _type string, pipe interfaces.IPipeFitting) bool { self.PipesMapMutex.Lock() @@ -83,11 +83,11 @@ func (self *Junction) RegisterPipe(name string, _type string, pipe interfaces.IP } /* - Does this junction have a pipe by this name? +HasPipe Does this junction have a pipe by this name? - - parameter name: the pipe to check for +- parameter name: the pipe to check for - - returns: Bool whether as pipe is registered with that name. +- returns: Bool whether as pipe is registered with that name. */ func (self *Junction) HasPipe(name string) bool { self.PipesMapMutex.RLock() @@ -97,11 +97,11 @@ func (self *Junction) HasPipe(name string) bool { } /* - Does this junction have an INPUT pipe by this name? +HasInputPipe Does this junction have an INPUT pipe by this name? - - parameter name: the pipe to check for +- parameter name: the pipe to check for - - returns: Bool whether an INPUT pipe is registered with that name. +- returns: Bool whether an INPUT pipe is registered with that name. */ func (self *Junction) HasInputPipe(name string) bool { self.PipesMapMutex.RLock() @@ -111,11 +111,11 @@ func (self *Junction) HasInputPipe(name string) bool { } /* - Does this junction have an OUTPUT pipe by this name? +HasOutputPipe Does this junction have an OUTPUT pipe by this name? - - parameter name: the pipe to check for +- parameter name: the pipe to check for - - returns: Bool whether an OUTPUT pipe is registered with that name. +- returns: Bool whether an OUTPUT pipe is registered with that name. */ func (self *Junction) HasOutputPipe(name string) bool { self.PipesMapMutex.RLock() @@ -125,13 +125,13 @@ func (self *Junction) HasOutputPipe(name string) bool { } /* - Remove the pipe with this name if it is registered. +RemovePipe Remove the pipe with this name if it is registered. - NOTE: You cannot have an INPUT pipe and an OUTPUT - pipe registered with the same name. All pipe names - must be unique regardless of type. +NOTE: You cannot have an INPUT pipe and an OUTPUT +pipe registered with the same name. All pipe names +must be unique regardless of type. - - parameter name: the pipe to remove +- parameter name: the pipe to remove */ func (self *Junction) RemovePipe(name string) { self.PipesMapMutex.Lock() @@ -156,11 +156,11 @@ func (self *Junction) RemovePipe(name string) { } /* - Retrieve the named pipe. +RetrievePipe Retrieve the named pipe. - - parameter name: the pipe to retrieve +- parameter name: the pipe to retrieve - - returns: IPipeFitting the pipe registered by the given name if it exists +- returns: IPipeFitting the pipe registered by the given name if it exists */ func (self *Junction) RetrievePipe(name string) interfaces.IPipeFitting { self.PipesMapMutex.RLock() @@ -170,15 +170,15 @@ func (self *Junction) RetrievePipe(name string) interfaces.IPipeFitting { } /* - Add a PipeListener to an INPUT pipe. +AddPipeListener Add a PipeListener to an INPUT pipe. - NOTE: there can only be one PipeListener per pipe, and the listener function must accept an IPipeMessage as its sole argument. +NOTE: there can only be one PipeListener per pipe, and the listener function must accept an IPipeMessage as its sole argument. - - parameter inputPipeName: the INPUT pipe to add a PipeListener to +- parameter inputPipeName: the INPUT pipe to add a PipeListener to - - parameter context: the calling context or 'this' object +- parameter context: the calling context or 'this' object - - parameter listener: the function on the context to call +- parameter listener: the function on the context to call */ func (self *Junction) AddPipeListener(inputPipeName string, context interface{}, listener func(message interfaces.IPipeMessage)) bool { success := false @@ -192,11 +192,11 @@ func (self *Junction) AddPipeListener(inputPipeName string, context interface{}, } /* - Send a message on an OUTPUT pipe. +SendMessage Send a message on an OUTPUT pipe. - - parameter outputPipeName: the OUTPUT pipe to send the message on +- parameter outputPipeName: the OUTPUT pipe to send the message on - - parameter message: the IPipeMessage to send +- parameter message: the IPipeMessage to send */ func (self *Junction) SendMessage(outputPipeName string, message interfaces.IPipeMessage) bool { self.PipesMapMutex.RLock() diff --git a/src/plumbing/JunctionMediator.go b/src/plumbing/JunctionMediator.go index 2cf8d51..ae75b26 100755 --- a/src/plumbing/JunctionMediator.go +++ b/src/plumbing/JunctionMediator.go @@ -20,7 +20,7 @@ const ( ) /* -Junction Mediator. +JunctionMediator Junction Mediator. A base class for handling the Pipe Junction in an IPipeAware Core. @@ -30,12 +30,12 @@ type JunctionMediator struct { } /* - List Notification Interests. +ListNotificationInterests List Notification Interests. - Returns the notification interests for this base class. - Override in subclass and call super.listNotificationInterests - to get this list, then add any sublcass interests to - the array before returning. +Returns the notification interests in this base class. +Override in subclass and call super.listNotificationInterests +to get this list, then add any sublcass interests to +the array before returning. */ func (self *JunctionMediator) ListNotificationInterests() []string { return []string{ @@ -44,14 +44,14 @@ func (self *JunctionMediator) ListNotificationInterests() []string { } /* - Handle Notification. +HandleNotification Handle Notification. - This provides the handling for common junction activities. It - accepts input and output pipes in response to IPipeAware - interface calls. +This provides the handling for common junction activities. It +accepts input and output pipes in response to IPipeAware +interface calls. - Override in subclass, and call super.handleNotification - if none of the subclass-specific notification names are matched. +Override in subclass, and call super.handleNotification +if none of the subclass-specific notification names are matched. */ func (self *JunctionMediator) HandleNotification(notification puremvc.INotification) { switch notification.Name() { @@ -72,16 +72,16 @@ func (self *JunctionMediator) HandleNotification(notification puremvc.INotificat } /* - Handle incoming pipe messages. +HandlePipeMessage Handle incoming pipe messages. - Override in subclass and handle messages appropriately for the module. +Override in subclass and handle messages appropriately for the module. */ func (self *JunctionMediator) HandlePipeMessage(message interfaces.IPipeMessage) { } /* - The Junction for this Module. +Junction The Junction for this Module. */ func (self *JunctionMediator) Junction() *Junction { return self.ViewComponent.(*Junction) diff --git a/src/plumbing/Pipe.go b/src/plumbing/Pipe.go index 838de07..414c47c 100755 --- a/src/plumbing/Pipe.go +++ b/src/plumbing/Pipe.go @@ -11,7 +11,7 @@ package plumbing import "github.com/puremvc/puremvc-go-util-pipes/src/interfaces" /* -Pipe. +Pipe Pipe. This is the most basic IPipeFitting, simply allowing the connection of an output @@ -22,14 +22,14 @@ type Pipe struct { } /* - Connect another PipeFitting to the output. +Connect another PipeFitting to the output. - PipeFittings connect to and write to other - PipeFittings in a one-way, syncrhonous chain. +PipeFittings connect to and write to other +PipeFittings in a one-way, synchronous chain. - - parameter output: IPipeFitting the output fitting to connect. +- parameter output: IPipeFitting the output fitting to connect. - - returns: Bool true if no other fitting was already connected. +- returns: Bool true if no other fitting was already connected. */ func (self *Pipe) Connect(output interfaces.IPipeFitting) bool { success := false @@ -41,16 +41,16 @@ func (self *Pipe) Connect(output interfaces.IPipeFitting) bool { } /* - Disconnect the Pipe Fitting connected to the output. +Disconnect the Pipe Fitting connected to the output. - This disconnects the output fitting, returning a - reference to it. If you were splicing another fitting - into a pipeline, you need to keep (at least briefly) - a reference to both sides of the pipeline in order to - connect them to the input and output of whatever - fitting that you're splicing in. +This disconnects the output fitting, returning a +reference to it. If you were splicing another fitting +into a pipeline, you need to keep (at least briefly) +a reference to both sides of the pipeline in order to +connect them to the input and output of whatever +fitting that you're splicing in. - - returns: IPipeFitting the now disconnected output fitting +- returns: IPipeFitting the now disconnected output fitting */ func (self *Pipe) Disconnect() interfaces.IPipeFitting { disconnectedFitting := self.Output @@ -59,11 +59,11 @@ func (self *Pipe) Disconnect() interfaces.IPipeFitting { } /* - Write the message to the connected output. +Write the message to the connected output. - - parameter message: the message to write +- parameter message: the message to write - - returns: Bool whether any connected downpipe outputs failed +- returns: Bool whether any connected down-pipe outputs failed */ func (self *Pipe) Write(message interfaces.IPipeMessage) bool { return self.Output.Write(message) diff --git a/src/plumbing/PipeListener.go b/src/plumbing/PipeListener.go index 81572d0..f74ffb0 100755 --- a/src/plumbing/PipeListener.go +++ b/src/plumbing/PipeListener.go @@ -11,7 +11,7 @@ package plumbing import "github.com/puremvc/puremvc-go-util-pipes/src/interfaces" /* -Pipe Listener. +PipeListener Pipe Listener Allows a class that does not implement IPipeFitting to be the final recipient of the messages in a pipeline. @@ -22,22 +22,22 @@ type PipeListener struct { } /* - Can't connect anything beyond this. - */ +Connect Can't connect anything beyond this. +*/ func (self *PipeListener) Connect(output interfaces.IPipeFitting) bool { return false } /* - Can't disconnect since you can't connect, either. - */ +Disconnect Can't disconnect since you can't connect, either. +*/ func (self *PipeListener) Disconnect() interfaces.IPipeFitting { return nil } /* - Write the message to the listener - */ +Write the message to the listener +*/ func (self *PipeListener) Write(message interfaces.IPipeMessage) bool { self.Listener(message) return true diff --git a/src/plumbing/Queue.go b/src/plumbing/Queue.go index 73daba5..c246202 100755 --- a/src/plumbing/Queue.go +++ b/src/plumbing/Queue.go @@ -16,10 +16,10 @@ import ( ) /* -Pipe Queue. +Queue Pipe Queue. The Queue always stores inbound messages until you send it -a FLUSH control message, at which point it writes its buffer +a FLUSH control message, at which point it writes it's buffer to the output pipe fitting. The Queue can be sent a SORT control message to go into sort-by-priority mode or a FIFO control message to cancel sort mode and return the @@ -38,6 +38,23 @@ type Queue struct { MessagesMutex sync.Mutex } +/** + * Write Handle the incoming message. + * + * Normal messages are enqueued. + * + * The FLUSH message type tells the Queue to write all + * stored messages to the output PipeFitting, then + * return to normal enqueuing operation. + * + * The SORT message type tells the Queue to sort all + * subsequent incoming messages by priority. If there + * are un-flushed messages in the queue, they will not be + * sorted unless a new message is sent before the next FLUSH. + * Sorting-by-priority behavior continues even after a FLUSH, + * and can be turned off by sending a FIFO message, which is + * the default behavior for enqueue/dequeue. + */ func (self *Queue) Write(message interfaces.IPipeMessage) bool { success := true @@ -60,9 +77,9 @@ func (self *Queue) Write(message interfaces.IPipeMessage) bool { } /* - Store a message. +Store a message. - - parameter message: the IPipeMessage to enqueue. +- parameter message: the IPipeMessage to enqueue. */ func (self *Queue) Store(message interfaces.IPipeMessage) { self.MessagesMutex.Lock() @@ -75,7 +92,7 @@ func (self *Queue) Store(message interfaces.IPipeMessage) { } /* - Sort the Messages by priority. +SortByPriority Sort the Messages by priority. */ type SortByPriority []interfaces.IPipeMessage @@ -90,11 +107,11 @@ func (s SortByPriority) Less(i, j int) bool { } /* - Flush the queue. +Flush the queue. - NOTE: This empties the queue. +NOTE: This empties the queue. - - returns: Bool true if all messages written successfully. +- returns: Bool true if all messages written successfully. */ func (self *Queue) Flush() bool { self.MessagesMutex.Lock() diff --git a/src/plumbing/TeeMerge.go b/src/plumbing/TeeMerge.go index affd843..d65aebb 100755 --- a/src/plumbing/TeeMerge.go +++ b/src/plumbing/TeeMerge.go @@ -11,7 +11,7 @@ package plumbing import "github.com/puremvc/puremvc-go-util-pipes/src/interfaces" /* -Merging Pipe Tee. +TeeMerge Merging Pipe Tee. Writes the messages from multiple input pipelines into a single output pipe fitting. @@ -21,12 +21,12 @@ type TeeMerge struct { } /* - Connect an input IPipeFitting. +ConnectInput Connect an input IPipeFitting. - NOTE: You can connect as many inputs as you want - by calling this method repeatedly. +NOTE: You can connect as many inputs as you want +by calling this method repeatedly. - - parameter input: the IPipeFitting to connect for input. +- parameter input: the IPipeFitting to connect for input. */ func (self *TeeMerge) ConnectInput(input interfaces.IPipeFitting) bool { return input.Connect(self) diff --git a/src/plumbing/TeeSplit.go b/src/plumbing/TeeSplit.go index c64bc32..d0161dd 100755 --- a/src/plumbing/TeeSplit.go +++ b/src/plumbing/TeeSplit.go @@ -14,7 +14,7 @@ import ( ) /* -Splitting Pipe Tee. +TeeSplit Splitting Pipe Tee. Writes input messages to multiple output pipe fittings. */ @@ -24,12 +24,12 @@ type TeeSplit struct { } /* - Connect the output IPipeFitting. +Connect the output IPipeFitting. - NOTE: You can connect as many outputs as you want - by calling this method repeatedly. +NOTE: You can connect as many outputs as you want +by calling this method repeatedly. - - parameter output: the IPipeFitting to connect for output. +- parameter output: the IPipeFitting to connect for output. */ func (self *TeeSplit) Connect(output interfaces.IPipeFitting) bool { self.outputsMutex.Lock() @@ -40,12 +40,12 @@ func (self *TeeSplit) Connect(output interfaces.IPipeFitting) bool { } /* - Disconnect the most recently connected output fitting. (LIFO) +Disconnect the most recently connected output fitting. (LIFO) - To disconnect all outputs, you must call this - method repeatedly untill it returns nil. +To disconnect all outputs, you must call this +method repeatedly untill it returns nil. - - parameter output: the IPipeFitting to connect for output. +- parameter output: the IPipeFitting to connect for output. */ func (self *TeeSplit) Disconnect() interfaces.IPipeFitting { self.outputsMutex.Lock() @@ -57,17 +57,17 @@ func (self *TeeSplit) Disconnect() interfaces.IPipeFitting { } /* - Disconnect a given output fitting. +DisconnectFitting Disconnect a given output fitting. - If the fitting passed in is connected - as an output of this TeeSplit, then - it is disconnected and the reference returned. +If the fitting passed in is connected +as an output of this TeeSplit, then +it is disconnected and the reference returned. - If the fitting passed in is not connected as an - output of this TeeSplit, then nil - is returned. +If the fitting passed in is not connected as an +output of this TeeSplit, then nil +is returned. - - parameter output: the IPipeFitting to connect for output. +- parameter output: the IPipeFitting to connect for output. */ func (self *TeeSplit) DisconnectFitting(target interfaces.IPipeFitting) interfaces.IPipeFitting { self.outputsMutex.Lock() @@ -85,14 +85,14 @@ func (self *TeeSplit) DisconnectFitting(target interfaces.IPipeFitting) interfac } /* - Write the message to all connected outputs. +Write the message to all connected outputs. - Returns false if any output returns false, - but all outputs are written to regardless. +Returns false if any output returns false, +but all outputs are written to regardless. - - parameter message: the message to write +- parameter message: the message to write - - returns: Boolean whether any connected outputs failed +- returns: Boolean whether any connected outputs failed */ func (self *TeeSplit) Write(message interfaces.IPipeMessage) bool { self.outputsMutex.RLock() diff --git a/test/plumbing/Filter_test.go b/test/plumbing/Filter_test.go index 8aca965..7ccfdba 100755 --- a/test/plumbing/Filter_test.go +++ b/test/plumbing/Filter_test.go @@ -20,7 +20,7 @@ Test the Filter class. */ /* - Test connecting input and output pipes to a filter as well as disconnecting the output. +Test connecting input and output pipes to a filter as well as disconnecting the output. */ func TestConnectingAndDisconnectingIOPipesFilter(t *testing.T) { // create output pipes 1 @@ -61,7 +61,7 @@ func TestConnectingAndDisconnectingIOPipesFilter(t *testing.T) { } /* - Test applying filter to a normal message. +Test applying filter to a normal message. */ func TestFilteringNormalMessage(t *testing.T) { // create messages to send to the queue @@ -115,7 +115,7 @@ func TestFilteringNormalMessage(t *testing.T) { } /* - Test setting filter to bypass mode, writing, then setting back to filter mode and writing. +Test setting filter to bypass mode, writing, then setting back to filter mode and writing. */ func TestBypassAndFilterModeToggle(t *testing.T) { // create messages to send to the queue @@ -178,10 +178,10 @@ func TestBypassAndFilterModeToggle(t *testing.T) { } // create filter control message - filterMessge := messages.NewFilterControlMessage(messages.FILTER, "scale", nil, nil) + filterMessage := messages.NewFilterControlMessage(messages.FILTER, "scale", nil, nil) // write bypass control message to the filter - filterWritten := filter.Write(filterMessge) + filterWritten := filter.Write(filterMessage) //let write normal message to the filter again written2 := filter.Write(message) @@ -215,7 +215,7 @@ func TestBypassAndFilterModeToggle(t *testing.T) { } /* - Test setting filter parameters by sending control message. +Test setting filter parameters by sending control message. */ func TestSetParamsByControlMessage(t *testing.T) { // create messages to send to the queue @@ -278,7 +278,7 @@ func TestSetParamsByControlMessage(t *testing.T) { } /* - Test setting filter function by sending control message. +Test setting filter function by sending control message. */ func TestSetFilterByControlMessage(t *testing.T) { // create messages to send to the queue @@ -346,24 +346,24 @@ func TestSetFilterByControlMessage(t *testing.T) { } /* - Test using a filter function to stop propagation of a message. - - The way to stop propagation of a message from within a filter - is to throw an error from the filter function. This test creates - two NORMAL messages, each with Rectangle objects that contain - a bozoLevel property. One has this property set to - 10, the other to 3. - - Creates a Filter, named 'bozoFilter' with an anonymous pipe listener - feeding the output back into this test. The filter funciton is an - anonymous function that throws an error if the message's bozoLevel - property is greater than the filter parameter bozoThreshold. - the anonymous filter parameters object has a bozoThreshold - value of 5. - - The messages are written to the filter and it is shown that the - message with the bozoLevel of 10 is not written, while - the message with the bozoLevel of 3 is. +Test using a filter function to stop propagation of a message. + +The way to stop propagation of a message from within a filter +is to throw an error from the filter function. This test creates +two NORMAL messages, each with Rectangle objects that contain +a bozoLevel property. One has this property set to +10, the other to 3. + +Creates a Filter, named 'bozoFilter' with an anonymous pipe listener +feeding the output back into this test. The filter funciton is an +anonymous function that throws an error if the message's bozoLevel +property is greater than the filter parameter bozoThreshold. +the anonymous filter parameters object has a bozoThreshold +value of 5. + +The messages are written to the filter and it is shown that the +message with the bozoLevel of 10 is not written, while +the message with the bozoLevel of 3 is. */ func TestUseFilterToStopAMessage(t *testing.T) { // create messages to send to the queue diff --git a/test/plumbing/Junction_test.go b/test/plumbing/Junction_test.go index 759ac1b..5cbc6ae 100755 --- a/test/plumbing/Junction_test.go +++ b/test/plumbing/Junction_test.go @@ -20,15 +20,15 @@ Test the Junction class. */ /* - Test registering an INPUT pipe to a junction. +Test registering an INPUT pipe to a junction. - Tests that the INPUT pipe is successfully registered and - that the hasPipe and hasInputPipe methods work. Then tests - that the pipe can be retrieved by name. +Tests that the INPUT pipe is successfully registered and +that the hasPipe and hasInputPipe methods work. Then tests +that the pipe can be retrieved by name. - Finally, it removes the registered INPUT pipe and tests - that all the previous assertions about it's registration - and accessability via the Junction are no longer true. +Finally, it removes the registered INPUT pipe and tests +that all the previous assertions about its registration +and accessibility via the Junction are no longer true. */ func TestRegisterRetrieveAndRemoveInputPipe(t *testing.T) { // create pipe connected to this test with a pipelistener @@ -76,15 +76,15 @@ func TestRegisterRetrieveAndRemoveInputPipe(t *testing.T) { } /* - Test registering an OUTPUT pipe to a junction. +Test registering an OUTPUT pipe to a junction. - Tests that the OUTPUT pipe is successfully registered and - that the hasPipe and hasOutputPipe methods work. Then tests - that the pipe can be retrieved by name. +Tests that the OUTPUT pipe is successfully registered and +that the hasPipe and hasOutputPipe methods work. Then tests +that the pipe can be retrieved by name. - Finally, it removes the registered OUTPUT pipe and tests - that all the previous assertions about it's registration - and accessability via the Junction are no longer true. +Finally, it removes the registered OUTPUT pipe and tests +that all the previous assertions about its registration +and accessibility via the Junction are no longer true. */ func TestRegisterRetrieveAndRemoveOutputPipe(t *testing.T) { // create pipe connected to this test with a pipelistener @@ -132,13 +132,13 @@ func TestRegisterRetrieveAndRemoveOutputPipe(t *testing.T) { } /* - Test adding a PipeListener to an Input Pipe. +Test adding a PipeListener to an Input Pipe. - Registers an INPUT Pipe with a Junction, then tests - the Junction's addPipeListener method, connecting - the output of the pipe back into to the test. If this - is successful, it sends a message down the pipe and - checks to see that it was received. +Registers an INPUT Pipe with a Junction, then tests +the Junction's addPipeListener method, connecting +the output of the pipe back into to the test. If this +is successful, it sends a message down the pipe and +checks to see that it was received. */ func TestAddingPipeListenerToAnInputPipe(t *testing.T) { // create pipe @@ -186,13 +186,13 @@ func TestAddingPipeListenerToAnInputPipe(t *testing.T) { } /* - Test using sendMessage on an OUTPUT pipe. +Test using sendMessage on an OUTPUT pipe. - Creates a Pipe, Junction and Message. - Adds the PipeListener to the Pipe. - Adds the Pipe to the Junction as an OUTPUT pipe. - uses the Junction's sendMessage method to send - the Message, then checks that it was received. +Creates a Pipe, Junction and Message. +Adds the PipeListener to the Pipe. +Adds the Pipe to the Junction as an OUTPUT pipe. +uses the Junction's sendMessage method to send +the Message, then checks that it was received. */ func TestSendMessageOnAnOutputPipe(t *testing.T) { // create pipe