Compare commits
	
		
			3 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | d159a8e392 | ||
|  | b4635386bb | ||
|  | c1708a5308 | 
							
								
								
									
										5
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								go.mod
									
									
									
									
									
								
							| @@ -3,10 +3,9 @@ module github.com/jar3b/nacl | |||||||
| go 1.13 | go 1.13 | ||||||
|  |  | ||||||
| require ( | require ( | ||||||
|  | 	github.com/golang/protobuf v1.3.3 // indirect | ||||||
| 	github.com/jar3b/grawt v0.1.5 | 	github.com/jar3b/grawt v0.1.5 | ||||||
| 	github.com/nats-io/nats-server/v2 v2.1.2 // indirect | 	github.com/nats-io/nats-streaming-server v0.17.0 // indirect | ||||||
| 	github.com/nats-io/nats-streaming-server v0.16.2 // indirect |  | ||||||
| 	github.com/nats-io/nats.go v1.9.1 | 	github.com/nats-io/nats.go v1.9.1 | ||||||
| 	github.com/nats-io/stan.go v0.6.0 | 	github.com/nats-io/stan.go v0.6.0 | ||||||
| 	github.com/sirupsen/logrus v1.4.2 |  | ||||||
| ) | ) | ||||||
|   | |||||||
							
								
								
									
										17
									
								
								nacl.go
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								nacl.go
									
									
									
									
									
								
							| @@ -17,6 +17,7 @@ type ( | |||||||
| 	Msg              = stan.Msg | 	Msg              = stan.Msg | ||||||
| 	NatsMsg          = nats.Msg | 	NatsMsg          = nats.Msg | ||||||
| 	Subscription     = stan.Subscription | 	Subscription     = stan.Subscription | ||||||
|  | 	NatsSubscription = nats.Subscription | ||||||
| ) | ) | ||||||
|  |  | ||||||
| func SetupNats(host string, port int, user string, pass string, closeHandler *grawt.CloseHandler) error { | func SetupNats(host string, port int, user string, pass string, closeHandler *grawt.CloseHandler) error { | ||||||
| @@ -64,6 +65,9 @@ func SetupStan(clusterName string, clientId string, host string, port int, user | |||||||
| } | } | ||||||
|  |  | ||||||
| func FinalizeStan(subscriptions *[]Subscription) error { | func FinalizeStan(subscriptions *[]Subscription) error { | ||||||
|  | 	if StanClient == nil { | ||||||
|  | 		return fmt.Errorf("stan client is not initialized") | ||||||
|  | 	} | ||||||
| 	for _, subscription := range *subscriptions { | 	for _, subscription := range *subscriptions { | ||||||
| 		_ = subscription.Unsubscribe() | 		_ = subscription.Unsubscribe() | ||||||
| 	} | 	} | ||||||
| @@ -74,3 +78,16 @@ func FinalizeStan(subscriptions *[]Subscription) error { | |||||||
|  |  | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func FinalizeNats(subscriptions *[]*NatsSubscription) error { | ||||||
|  | 	if NatsClient == nil { | ||||||
|  | 		return fmt.Errorf("stan client is not initialized") | ||||||
|  | 	} | ||||||
|  | 	for _, subscription := range *subscriptions { | ||||||
|  | 		_ = subscription.Unsubscribe() | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	NatsClient.Close() | ||||||
|  |  | ||||||
|  | 	return nil | ||||||
|  | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user