83577a7d5d
removed amber files. replacing with angular removed queue package in favor or worker package removed channel package in favor of pubsub package
30 lines
447 B
Go
30 lines
447 B
Go
package pubsub
|
|
|
|
import (
|
|
"bytes"
|
|
)
|
|
|
|
type Buffer struct {
|
|
buf bytes.Buffer
|
|
channel *Channel
|
|
}
|
|
|
|
func NewBuffer(channel *Channel) *Buffer {
|
|
return &Buffer{
|
|
channel: channel,
|
|
}
|
|
}
|
|
|
|
func (b *Buffer) Write(p []byte) (n int, err error) {
|
|
n, err = b.buf.Write(p)
|
|
b.channel.Publish(p)
|
|
return
|
|
}
|
|
|
|
func (b *Buffer) WriteString(s string) (n int, err error) {
|
|
return b.Write([]byte(s))
|
|
}
|
|
|
|
func (b *Buffer) Bytes() []byte {
|
|
return b.buf.Bytes()
|
|
}
|