feat: add pubsub
This commit is contained in:
		
							
								
								
									
										27
									
								
								internal/pkg/pubsub/pubsub.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								internal/pkg/pubsub/pubsub.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
package pubsub
 | 
			
		||||
 | 
			
		||||
import "context"
 | 
			
		||||
 | 
			
		||||
type Subject string
 | 
			
		||||
 | 
			
		||||
func (subject Subject) String() string {
 | 
			
		||||
	return string(subject)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type Message interface{}
 | 
			
		||||
 | 
			
		||||
type Publishing struct{}
 | 
			
		||||
 | 
			
		||||
type PublishOption func(*Publishing)
 | 
			
		||||
 | 
			
		||||
type Publisher interface {
 | 
			
		||||
	Publish(context.Context, Subject, Message, ...PublishOption) error
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type MessageHandler interface {
 | 
			
		||||
	HandleMessage(context.Context, *Message) error
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type Subscriber interface {
 | 
			
		||||
	Subscribe(context.Context, Subject, MessageHandler) error
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user