1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-07-04 12:03:41 +02:00

move writer interface and redis publish from api module as these are for the server side.

This commit is contained in:
Henrik Hautakoski 2023-11-25 15:12:08 +01:00
parent a94fbe191a
commit 24bf44a175
5 changed files with 11 additions and 5 deletions

View file

@ -4,6 +4,7 @@ import (
"context" "context"
"github.com/eosswedenorg/thalos/api" "github.com/eosswedenorg/thalos/api"
. "github.com/eosswedenorg/thalos/api/redis"
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"
) )

View file

@ -5,6 +5,7 @@ import (
"testing" "testing"
"github.com/eosswedenorg/thalos/api" "github.com/eosswedenorg/thalos/api"
. "github.com/eosswedenorg/thalos/api/redis"
"github.com/go-redis/redismock/v9" "github.com/go-redis/redismock/v9"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"

View file

@ -1,4 +1,6 @@
package api package driver
import "github.com/eosswedenorg/thalos/api"
// Writer interface defines the required methods // Writer interface defines the required methods
// to send messages over an channel. // to send messages over an channel.
@ -7,7 +9,7 @@ package api
type Writer interface { type Writer interface {
// Write writes a message over a channel. // Write writes a message over a channel.
// The message may or may not be buffered depending on the implementation. // The message may or may not be buffered depending on the implementation.
Write(channel Channel, payload []byte) error Write(channel api.Channel, payload []byte) error
// Flush writes any buffered messages to the channel. // Flush writes any buffered messages to the channel.
// If the implementation does not support buffering. this is a noop. // If the implementation does not support buffering. this is a noop.

View file

@ -7,6 +7,7 @@ import (
"github.com/eosswedenorg/thalos/api" "github.com/eosswedenorg/thalos/api"
"github.com/eosswedenorg/thalos/api/message" "github.com/eosswedenorg/thalos/api/message"
"github.com/eosswedenorg/thalos/app/abi" "github.com/eosswedenorg/thalos/app/abi"
"github.com/eosswedenorg/thalos/app/driver"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
@ -38,7 +39,7 @@ type ShipProcessor struct {
abi *abi.AbiManager abi *abi.AbiManager
// Writer to send messages to. // Writer to send messages to.
writer api.Writer writer driver.Writer
// Encoder used to encode messages // Encoder used to encode messages
encode message.Encoder encode message.Encoder
@ -51,7 +52,7 @@ type ShipProcessor struct {
} }
// SpawnProcessor creates a new ShipProccessor that consumes the shipclient.Stream passed to it. // SpawnProcessor creates a new ShipProccessor that consumes the shipclient.Stream passed to it.
func SpawnProccessor(shipStream *shipclient.Stream, writer api.Writer, abi *abi.AbiManager, codec message.Codec) *ShipProcessor { func SpawnProccessor(shipStream *shipclient.Stream, writer driver.Writer, abi *abi.AbiManager, codec message.Codec) *ShipProcessor {
processor := &ShipProcessor{ processor := &ShipProcessor{
abi: abi, abi: abi,
writer: writer, writer: writer,

View file

@ -22,6 +22,7 @@ import (
"github.com/eosswedenorg/thalos/app" "github.com/eosswedenorg/thalos/app"
"github.com/eosswedenorg/thalos/app/abi" "github.com/eosswedenorg/thalos/app/abi"
"github.com/eosswedenorg/thalos/app/config" "github.com/eosswedenorg/thalos/app/config"
driver "github.com/eosswedenorg/thalos/app/driver/redis"
. "github.com/eosswedenorg/thalos/app/log" . "github.com/eosswedenorg/thalos/app/log"
"github.com/nikoksr/notify" "github.com/nikoksr/notify"
"github.com/nikoksr/notify/service/telegram" "github.com/nikoksr/notify/service/telegram"
@ -314,7 +315,7 @@ func main() {
processor := app.SpawnProccessor( processor := app.SpawnProccessor(
shClient, shClient,
api_redis.NewPublisher(context.Background(), rdb, api_redis.Namespace{ driver.NewPublisher(context.Background(), rdb, api_redis.Namespace{
Prefix: conf.Redis.Prefix, Prefix: conf.Redis.Prefix,
ChainID: chain_id, ChainID: chain_id,
}), }),