Fairly new to go. I'm trying to modify this go scribe server implementation:
https://github.com/samuel/go-thrift/blob/master/examples/scribe_server/main.go
I'd like to pass a channel to the Log()
func so I can pass scribe data to a separate go routine but I'm not sure how to modify scribe/thrift.go
to extend the log interface to be
Log(messages []*scribe.LogEntry, counts chan string)
(or whether this is even needed and if there is some way to extend the interface without messing with the original library).
You can't modify or extend an already declared interface, you can only create a new one, possibly extending the old one. But you cannot re-declare methods in the interface.
This means that what you want to do (modify the
Scribe
interface so that itsLog
method has a different signature) is not possible.What you can do is to have a type which holds your channel and embeds the structure you want to extend.
Example:
The example above defines a struct which embeds a
Scribe
and defines its ownLog
method, utilizing the one of the embeddedScribe
. This struct can be used wherever aScribe
is expected (as it implements theScribe
interface) but holds your additional channel.