StefanKopieczek / gossip

SIP stack in Golang
GNU Lesser General Public License v2.1
336 stars 109 forks source link

Question: Why did you use channels as arguments in your parser? #11

Closed clintberry closed 9 years ago

clintberry commented 9 years ago

This code here: https://github.com/StefanKopieczek/gossip/blob/master/parser/parser.go#L103

I am trying to get a grasp on why you would create the parser this way. Is there any particular reason or was it just a pattern you prefer using?

clintberry commented 9 years ago

Nevermind, I think I see why. You allow streaming of data into a writer into the parser. You can stream multiple streams into the parser and it needs to be able to return multiple sip messages, so you created a channel for it. Makes sense.

StefanKopieczek commented 9 years ago

Exactly right. It's not quite as clean as I'd like though, as I had to do some gymnastics to reuse it for unstreamed protocols as well as streamed. I've rewritten it a few times already, but I'm probably not quite done with tidying it up :)