-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#130]: feature: http health and readiness checks
- Loading branch information
Showing
10 changed files
with
218 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package grpc | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/roadrunner-server/api/v4/plugins/v1/status" | ||
"github.com/roadrunner-server/sdk/v4/fsm" | ||
) | ||
|
||
// Status return status of the particular plugin | ||
func (p *Plugin) Status() (*status.Status, error) { | ||
p.mu.RLock() | ||
defer p.mu.RUnlock() | ||
|
||
workers := p.gPool.Workers() | ||
|
||
for i := 0; i < len(workers); i++ { | ||
if workers[i].State().IsActive() { | ||
return &status.Status{ | ||
Code: http.StatusOK, | ||
}, nil | ||
} | ||
} | ||
// if there are no workers, threat this as error | ||
return &status.Status{ | ||
Code: http.StatusServiceUnavailable, | ||
}, nil | ||
} | ||
|
||
// Ready return readiness status of the particular plugin | ||
func (p *Plugin) Ready() (*status.Status, error) { | ||
p.mu.RLock() | ||
defer p.mu.RUnlock() | ||
|
||
workers := p.gPool.Workers() | ||
|
||
for i := 0; i < len(workers); i++ { | ||
// If state of the worker is ready (at least 1) | ||
// we assume, that plugin's worker pool is ready | ||
if workers[i].State().Compare(fsm.StateReady) { | ||
return &status.Status{ | ||
Code: http.StatusOK, | ||
}, nil | ||
} | ||
} | ||
// if there are no workers, threat this as no content error | ||
return &status.Status{ | ||
Code: http.StatusServiceUnavailable, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
version: '3' | ||
|
||
rpc: | ||
listen: "tcp://127.0.0.1:6111" | ||
|
||
server: | ||
command: "php php_test_files/worker-grpc.php" | ||
relay: "pipes" | ||
relay_timeout: "20s" | ||
|
||
status: | ||
address: "127.0.0.1:35544" | ||
|
||
# GRPC service configuration | ||
grpc: | ||
listen: "tcp://127.0.0.1:9111" | ||
proto: | ||
- "proto/test/test.proto" | ||
max_send_msg_size: 50 | ||
max_recv_msg_size: 50 | ||
max_connection_idle: 0s | ||
max_connection_age: 0s | ||
max_connection_age_grace: 0s | ||
max_concurrent_streams: 10 | ||
ping_time: 1s | ||
timeout: 200s | ||
pool: | ||
num_workers: 1 | ||
allocate_timeout: 60s | ||
destroy_timeout: 5s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.