mirror of
				https://github.com/go-micro/go-micro.git
				synced 2025-10-30 23:27:41 +02:00 
			
		
		
		
	
		
			
				
	
	
		
			31 lines
		
	
	
		
			718 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			718 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Package nats provides a NATS control plane
 | |
| package nats
 | |
| 
 | |
| import (
 | |
| 	"github.com/micro/go-micro"
 | |
| 	broker "github.com/micro/go-plugins/broker/nats"
 | |
| 	registry "github.com/micro/go-plugins/registry/nats"
 | |
| 	transport "github.com/micro/go-plugins/transport/nats"
 | |
| )
 | |
| 
 | |
| // NewService returns a NATS micro.Service
 | |
| func NewService(opts ...micro.Option) micro.Service {
 | |
| 	// initialise nats components
 | |
| 	b := broker.NewBroker()
 | |
| 	r := registry.NewRegistry()
 | |
| 	t := transport.NewTransport()
 | |
| 
 | |
| 	// create new options
 | |
| 	options := []micro.Option{
 | |
| 		micro.Broker(b),
 | |
| 		micro.Registry(r),
 | |
| 		micro.Transport(t),
 | |
| 	}
 | |
| 
 | |
| 	// append user options
 | |
| 	options = append(options, opts...)
 | |
| 
 | |
| 	// return a nats service
 | |
| 	return micro.NewService(options...)
 | |
| }
 |