1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-08-23 19:48:12 +02:00

transport/publisher.go: rename to writer.go

This commit is contained in:
Henrik Hautakoski 2023-03-07 11:41:22 +01:00
parent b3f773655d
commit f9fc88b0fb
4 changed files with 20 additions and 20 deletions

View file

@ -22,7 +22,7 @@ func NewPublisher(client *redis.Client, ns Namespace) *Publisher {
}
}
func (r *Publisher) Publish(channel transport.ChannelInterface, payload []byte) error {
func (r *Publisher) Write(channel transport.ChannelInterface, payload []byte) error {
return r.pipeline.Publish(r.ctx, r.ns.NewKey(channel).String(), payload).Err()
}

View file

@ -18,8 +18,8 @@ func TestPublisher_Publish(t *testing.T) {
mock.ExpectPublish("ship::id::test", []byte("some string")).SetVal(0)
mock.ExpectPublish("ship::id::test2", []byte("some other string")).SetVal(0)
assert.NoError(t, pub.Publish(transport.Channel{"test"}, []byte("some string")))
assert.NoError(t, pub.Publish(transport.Channel{"test2"}, []byte("some other string")))
assert.NoError(t, pub.Write(transport.Channel{"test"}, []byte("some string")))
assert.NoError(t, pub.Write(transport.Channel{"test2"}, []byte("some other string")))
assert.NoError(t, pub.Flush())
assert.NoError(t, mock.ExpectationsWereMet())

View file

@ -1,11 +1,11 @@
package transport
// Publisher interface defines the required methods
// to send messages over channel.
type Publisher interface {
// Publish a message to a channel.
// Writer interface defines the required methods
// to send messages over an channel.
type Writer interface {
// Write writes a message over a channel.
// The message may or may not be buffered depending on the implementation.
Publish(channel ChannelInterface, payload []byte) error
Write(channel ChannelInterface, payload []byte) error
// Flush writes any buffered messages to the channel.
// If the implementation does not support buffering. this is a noop.