forked from actionpay/postmanq
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
420 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,14 +11,14 @@ func main() { | |
|
||
// amqpURI := "amqp://admin:[email protected]:5672/postmanq" | ||
amqpURI := "amqp://solomonov:123123123@localhost:5672/postmanq" | ||
messageCount := 10 | ||
messageCount := 1 | ||
// hasError := true | ||
hasError := false | ||
exchange := "postmanq" | ||
// exchange := "postmanq.failure.recipient" | ||
envelope := "[email protected]" | ||
recipient := "[email protected]" | ||
// recipient := "[email protected]" | ||
recipient := "[email protected]" | ||
//recipient := "[email protected]" | ||
// recipient := "[email protected]"" | ||
// recipient := "[email protected]" | ||
// recipient := "[email protected]" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package recipient | ||
|
||
import ( | ||
"cmd/go/testdata/src/vend/x/vendor/r" | ||
"net" | ||
"net/textproto" | ||
) | ||
|
||
//type RecipientState int | ||
// | ||
//const ( | ||
// Ehlo RecipientState = iota | ||
// Helo | ||
// Rcpt | ||
// Data | ||
// Rset | ||
// Noop | ||
// Vrfy | ||
// Quit | ||
//) | ||
// | ||
//var ( | ||
// nexts = map[RecipientState][]RecipientState { | ||
// Ehlo: []RecipientState{Mail, Rset, Noop, Quit, Vrfy}, | ||
// Helo: []RecipientState{Mail, Rset, Noop, Quit, Vrfy}, | ||
// Mail: []RecipientState{Rcpt, Rset, Noop, Quit}, | ||
// Rcpt: []RecipientState{Data, Rcpt, Rset, Noop, Quit}, | ||
// Data: []RecipientState{Mail, Rset, Noop, Quit}, | ||
// Rset: []RecipientState{Mail, Rset, Noop, Quit}, | ||
// Noop: []RecipientState{}, | ||
// Vrfy: []RecipientState{}, | ||
// Quit: []RecipientState{}, | ||
// } | ||
//) | ||
// | ||
//func (r RecipientState) getName() []byte {} | ||
|
||
type Recipient struct { | ||
id int | ||
state State | ||
conn net.Conn | ||
txt *textproto.Conn | ||
} | ||
|
||
func newRecipient(id int, events chan *Event) { | ||
mail := new(MailState) | ||
mail.SetPossibles([]State{}) | ||
|
||
ehlo := new(EhloState) | ||
ehlo.SetNext(mail) | ||
ehlo.SetPossibles([]State{}) | ||
|
||
conn := new(ConnectState) | ||
conn.SetNext(ehlo) | ||
conn.SetPossibles([]State{}) | ||
|
||
recipient := &Recipient{ | ||
id: id, | ||
state: conn, | ||
} | ||
for event := range events { | ||
recipient.handle(event) | ||
} | ||
} | ||
|
||
func (r *Recipient) handle(event *Event) { | ||
r.txt = textproto.NewConn(event.conn) | ||
|
||
for { | ||
r.state.SetEvent(event) | ||
status := r.state.Read(r.txt) | ||
goto handleStatus | ||
|
||
handleStatus: | ||
switch status { | ||
case SuccessStatus: | ||
r.state.Write(r.txt) | ||
r.state = r.state.GetNext() | ||
|
||
case FailureStatus: | ||
r.state.Write(r.txt) | ||
|
||
case PossibleStatus: | ||
var possibleStatus StateStatus | ||
for _, possible := range r.state.GetPossibles() { | ||
possible.SetEvent(event) | ||
possibleStatus = possible.Read(r.txt) | ||
if possibleStatus == SuccessStatus { | ||
r.state = possible | ||
status = possibleStatus | ||
goto handleStatus | ||
} | ||
} | ||
r.txt.Cmd("500 Syntax error, command unrecognized") | ||
|
||
} | ||
return | ||
} | ||
} |
Oops, something went wrong.