pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [pulsar] wolfstudy commented on a change in pull request #6031: [Issue 4175] [pulsar-function-go] Add Go Function heartbeat (and gRPC service) for production usage
Date Wed, 15 Jan 2020 15:45:35 GMT
wolfstudy commented on a change in pull request #6031: [Issue 4175] [pulsar-function-go] Add
Go Function heartbeat (and gRPC service) for production usage
URL: https://github.com/apache/pulsar/pull/6031#discussion_r366945364
 
 

 ##########
 File path: pulsar-function-go/pf/instance.go
 ##########
 @@ -35,19 +36,57 @@ type goInstance struct {
 	producer  pulsar.Producer
 	consumers map[string]pulsar.Consumer
 	client    pulsar.Client
+	lastHealthCheckTs int64
 }
 
+
 // newGoInstance init goInstance and init function context
 func newGoInstance() *goInstance {
 	goInstance := &goInstance{
 		context:   NewFuncContext(),
 		consumers: make(map[string]pulsar.Consumer),
 	}
+	now := time.Now()
+	goInstance.lastHealthCheckTs = now.UnixNano()
 	return goInstance
 }
 
+func (gi *goInstance) processSpawnerHealthCheckTimer(tkr *time.Ticker){
+	log.Info("Starting processSpawnerHealthCheckTimer")
+	now := time.Now()
+	maxIdleTime := gi.context.GetMaxIdleTime()
+	timeSinceLastCheck := now.UnixNano() - gi.lastHealthCheckTs
+	if (timeSinceLastCheck) > (maxIdleTime)  {
+		log.Errorf("Haven't received health check from spawner in a while. Stopping instance...")
+		gi.close()
+		// os.Exit(1)
 
 Review comment:
   please remove the commets

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message