Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
saadshams committed Dec 13, 2023
1 parent 8e2537e commit c104276
Show file tree
Hide file tree
Showing 21 changed files with 276 additions and 235 deletions.
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/)
Expand Down
6 changes: 4 additions & 2 deletions VERSION
Original file line number Diff line number Diff line change
@@ -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 <saad.shams@puremvc.org>
--------------------------------------------------------------------------
1.0 - Initial release.

1.1 - Updated to use Go 1.21. Minor Updates.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions go.sum

This file was deleted.

2 changes: 1 addition & 1 deletion src/interfaces/IPipeAware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/interfaces/IPipeFitting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
*/
Expand Down
6 changes: 3 additions & 3 deletions src/interfaces/IPipeMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 9 additions & 9 deletions src/messages/FilterControlMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const (
)

/*
Filter Control Message.
FilterControlMessage Filter Control Message.
A special message type for controlling the behavior of a Filter.
Expand Down Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions src/messages/Message.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/messages/QueueControlMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const (
)

/*
Queue Control Message.
QueueControlMessage Queue Control Message.
A special message for controlling the behavior of a Queue.
Expand All @@ -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}}
}
58 changes: 29 additions & 29 deletions src/plumbing/Filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
Loading

0 comments on commit c104276

Please sign in to comment.