-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.go
More file actions
24 lines (20 loc) · 849 Bytes
/
plugin.go
File metadata and controls
24 lines (20 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Package workflowpluginbroker provides the NATS broker workflow plugin.
package workflowpluginbroker
import (
"context"
"github.com/GoCodeAlone/workflow-plugin-broker/internal"
)
// Broker is the public interface for the NATS broker.
type Broker interface {
Start(ctx context.Context) error
Stop(ctx context.Context) error
Publish(subject string, data []byte) error
Subscribe(subject string, handler func([]byte)) error
SubscribeWithSubject(subject string, handler func(subject string, data []byte)) error
SubscribeDurable(subject, consumerName string, handler func([]byte)) error
}
// NewBrokerPlugin creates a new NATS broker plugin instance from the given config.
// Config keys: url (string), stream (string), jetstream (bool).
func NewBrokerPlugin(name string, cfg map[string]any) Broker {
return internal.NewPlugin(name, cfg)
}