GithubHelp home page GithubHelp logo

Comments (5)

anupriya17 avatar anupriya17 commented on May 26, 2024

A Pubsub Interface like this will help, I just copied the redis pubsub methods:

type Message struct {
	Channel      string
	Payload      string
}

type PubSub interface {
	Subscribe(ctx context.Context, channels ...string) error
	PSubscribe(ctx context.Context, patterns ...string) error
	SSubscribe(ctx context.Context, channels ...string) error
	Unsubscribe(ctx context.Context, channels ...string) error
	PUnsubscribe(ctx context.Context, patterns ...string) error
	SUnsubscribe(ctx context.Context, channels ...string) error
	Ping(ctx context.Context, payload ...string) error
	ReceiveTimeout(ctx context.Context, timeout time.Duration) (interface{}, error)
	Receive(ctx context.Context) (interface{}, error)
	ReceiveMessage(ctx context.Context) (*Message, error)
	Channel(opts ...ChannelOption) <-chan *Message
	Close() error
}

type ChannelOption func(*channelOptions)

type channelOptions struct {
	size        int
	maxInterval int64
}

func WithChannelSize(size int) ChannelOption {
	return func(opts *channelOptions) {
		opts.size = size
	}
}

func WithMaxInterval(maxInterval int64) ChannelOption {
	return func(opts *channelOptions) {
		opts.maxInterval = maxInterval
	}
}

from asynq.

yoshdog avatar yoshdog commented on May 26, 2024

ok seems like there is already a broker interface
https://github.com/hibiken/asynq/blob/master/internal/base/base.go#L715-L755

So we would just need to implement one for every type... eg: SQS, RabbitMQ, PUB SUB etc...

from asynq.

anupriya17 avatar anupriya17 commented on May 26, 2024

Thanks. broker interface depends on redis pubsub currently.
https://github.com/hibiken/asynq/blob/master/internal/base/base.go#L751

IMO to decouple pub/sub to its own interface. We don't need all the methods

from asynq.

anhoder avatar anhoder commented on May 26, 2024

Looking forward to this feature👀

from asynq.

bowenli86 avatar bowenli86 commented on May 26, 2024

+1

from asynq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.