mirror of
https://github.com/go-micro/go-micro.git
synced 2025-08-10 21:52:01 +02:00
publisher => event
This commit is contained in:
18
micro.go
18
micro.go
@@ -62,12 +62,15 @@ type Resource interface {
|
||||
}
|
||||
*/
|
||||
|
||||
// Publisher is uses to publish messages to a topic
|
||||
type Publisher interface {
|
||||
// Event is used to publish messages to a topic
|
||||
type Event interface {
|
||||
// Publish publishes a message to the event topic
|
||||
Publish(ctx context.Context, msg interface{}, opts ...client.PublishOption) error
|
||||
}
|
||||
|
||||
// Type alias to satisfy the deprecation
|
||||
type Publisher = Event
|
||||
|
||||
type Option func(*Options)
|
||||
|
||||
var (
|
||||
@@ -95,12 +98,17 @@ func NewFunction(opts ...Option) Function {
|
||||
return newFunction(opts...)
|
||||
}
|
||||
|
||||
// NewPublisher returns a new Publisher
|
||||
func NewPublisher(topic string, c client.Client) Publisher {
|
||||
// NewEvent creates a new event publisher
|
||||
func NewEvent(topic string, c client.Client) Event {
|
||||
if c == nil {
|
||||
c = client.NewClient()
|
||||
}
|
||||
return &publisher{c, topic}
|
||||
return &event{c, topic}
|
||||
}
|
||||
|
||||
// Deprecated: NewPublisher returns a new Publisher
|
||||
func NewPublisher(topic string, c client.Client) Event {
|
||||
return NewEvent(topic, c)
|
||||
}
|
||||
|
||||
// RegisterHandler is syntactic sugar for registering a handler
|
||||
|
Reference in New Issue
Block a user