Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Clutch
Commits
71565c5e
Commit
71565c5e
authored
3 years ago
by
Daniel Hochman
Browse files
Options
Download
Email Patches
Plain Diff
add option to enable healthcheck
parent
67a5e235
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
api/config/service/temporal/v1/temporal.proto
+6
-0
api/config/service/temporal/v1/temporal.proto
backend/api/config/service/temporal/v1/temporal.pb.go
+17
-2
backend/api/config/service/temporal/v1/temporal.pb.go
backend/api/config/service/temporal/v1/temporal.pb.validate.go
+2
-0
...nd/api/config/service/temporal/v1/temporal.pb.validate.go
backend/service/temporal/temporal.go
+12
-9
backend/service/temporal/temporal.go
backend/service/temporal/temporal_test.go
+2
-2
backend/service/temporal/temporal_test.go
frontend/api/src/index.d.ts
+6
-0
frontend/api/src/index.d.ts
frontend/api/src/index.js
+19
-1
frontend/api/src/index.js
with
64 additions
and
14 deletions
+64
-14
api/config/service/temporal/v1/temporal.proto
+
6
-
0
View file @
71565c5e
...
...
@@ -17,4 +17,10 @@ message Config {
message
ConnectionOptions
{
bool
use_system_ca_bundle
=
1
;
// If set to true, the Temporal client will attempt to connect to the Temporal server when GetNamespaceClient is
// called. In general the health check should not be enabled unless the only purpose of the configured Clutch instance
// is to execute Temporal worker code, as it may block Clutch from running at all in the event Temporal is down. This
// can create a circular dependency if Clutch also hosts tools that could be used to mitigate a Temporal outage.
bool
enable_health_check
=
2
;
}
This diff is collapsed.
Click to expand it.
backend/api/config/service/temporal/v1/temporal.pb.go
+
17
-
2
View file @
71565c5e
...
...
@@ -92,6 +92,11 @@ type ConnectionOptions struct {
unknownFields
protoimpl
.
UnknownFields
UseSystemCaBundle
bool
`protobuf:"varint,1,opt,name=use_system_ca_bundle,json=useSystemCaBundle,proto3" json:"use_system_ca_bundle,omitempty"`
// If set to true, the Temporal client will attempt to connect to the Temporal server when GetNamespaceClient is
// called. In general the health check should not be enabled unless the only purpose of the configured Clutch instance
// is to execute Temporal worker code, as it may block Clutch from running at all in the event Temporal is down. This
// can create a circular dependency if Clutch also hosts tools that could be used to mitigate a Temporal outage.
EnableHealthCheck
bool
`protobuf:"varint,2,opt,name=enable_health_check,json=enableHealthCheck,proto3" json:"enable_health_check,omitempty"`
}
func
(
x
*
ConnectionOptions
)
Reset
()
{
...
...
@@ -133,6 +138,13 @@ func (x *ConnectionOptions) GetUseSystemCaBundle() bool {
return
false
}
func
(
x
*
ConnectionOptions
)
GetEnableHealthCheck
()
bool
{
if
x
!=
nil
{
return
x
.
EnableHealthCheck
}
return
false
}
var
File_config_service_temporal_v1_temporal_proto
protoreflect
.
FileDescriptor
var
file_config_service_temporal_v1_temporal_proto_rawDesc
=
[]
byte
{
...
...
@@ -153,11 +165,14 @@ var file_config_service_temporal_v1_temporal_proto_rawDesc = []byte{
0x63
,
0x65
,
0x2e
,
0x74
,
0x65
,
0x6d
,
0x70
,
0x6f
,
0x72
,
0x61
,
0x6c
,
0x2e
,
0x76
,
0x31
,
0x2e
,
0x43
,
0x6f
,
0x6e
,
0x6e
,
0x65
,
0x63
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x4f
,
0x70
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x73
,
0x52
,
0x11
,
0x63
,
0x6f
,
0x6e
,
0x6e
,
0x65
,
0x63
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x4f
,
0x70
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x73
,
0x22
,
0x
4
4
,
0x0a
,
0x11
,
0x43
,
0x6f
,
0x6e
,
0x6e
,
0x65
,
0x63
,
0x74
,
0x69
,
0x6f
,
0x6f
,
0x6e
,
0x73
,
0x22
,
0x
7
4
,
0x0a
,
0x11
,
0x43
,
0x6f
,
0x6e
,
0x6e
,
0x65
,
0x63
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x4f
,
0x70
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x73
,
0x12
,
0x2f
,
0x0a
,
0x14
,
0x75
,
0x73
,
0x65
,
0x5f
,
0x73
,
0x79
,
0x73
,
0x74
,
0x65
,
0x6d
,
0x5f
,
0x63
,
0x61
,
0x5f
,
0x62
,
0x75
,
0x6e
,
0x64
,
0x6c
,
0x65
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x08
,
0x52
,
0x11
,
0x75
,
0x73
,
0x65
,
0x53
,
0x79
,
0x73
,
0x74
,
0x65
,
0x6d
,
0x43
,
0x61
,
0x42
,
0x75
,
0x6e
,
0x64
,
0x6c
,
0x65
,
0x42
,
0x4a
,
0x5a
,
0x48
,
0x67
,
0x69
,
0x74
,
0x6d
,
0x43
,
0x61
,
0x42
,
0x75
,
0x6e
,
0x64
,
0x6c
,
0x65
,
0x12
,
0x2e
,
0x0a
,
0x13
,
0x65
,
0x6e
,
0x61
,
0x62
,
0x6c
,
0x65
,
0x5f
,
0x68
,
0x65
,
0x61
,
0x6c
,
0x74
,
0x68
,
0x5f
,
0x63
,
0x68
,
0x65
,
0x63
,
0x6b
,
0x18
,
0x02
,
0x20
,
0x01
,
0x28
,
0x08
,
0x52
,
0x11
,
0x65
,
0x6e
,
0x61
,
0x62
,
0x6c
,
0x65
,
0x48
,
0x65
,
0x61
,
0x6c
,
0x74
,
0x68
,
0x43
,
0x68
,
0x65
,
0x63
,
0x6b
,
0x42
,
0x4a
,
0x5a
,
0x48
,
0x67
,
0x69
,
0x74
,
0x68
,
0x75
,
0x62
,
0x2e
,
0x63
,
0x6f
,
0x6d
,
0x2f
,
0x6c
,
0x79
,
0x66
,
0x74
,
0x2f
,
0x63
,
0x6c
,
0x75
,
0x74
,
0x63
,
0x68
,
0x2f
,
0x62
,
0x61
,
0x63
,
0x6b
,
0x65
,
0x6e
,
0x64
,
0x2f
,
0x61
,
0x70
,
0x69
,
0x2f
,
0x63
,
0x6f
,
0x6e
,
0x66
,
0x69
,
0x67
,
0x2f
,
0x73
,
0x65
,
0x72
,
0x76
,
0x69
,
0x63
,
0x65
,
0x2f
,
0x74
,
...
...
This diff is collapsed.
Click to expand it.
backend/api/config/service/temporal/v1/temporal.pb.validate.go
+
2
-
0
View file @
71565c5e
...
...
@@ -207,6 +207,8 @@ func (m *ConnectionOptions) validate(all bool) error {
// no validation rules for UseSystemCaBundle
// no validation rules for EnableHealthCheck
if
len
(
errors
)
>
0
{
return
ConnectionOptionsMultiError
(
errors
)
}
...
...
This diff is collapsed.
Click to expand it.
backend/service/temporal/temporal.go
+
12
-
9
View file @
71565c5e
...
...
@@ -39,18 +39,21 @@ func newClient(cfg *temporalv1.Config, logger *zap.Logger, scope tally.Scope) (C
metricsHandler
:
newMetricsHandler
(
scope
),
logger
:
newTemporalLogger
(
logger
),
//
Explicitly d
isable the healthcheck (i.e. connect lazily)
so service instantiation will not block server startup
.
//
D
isable the healthcheck
by default
(i.e. connect lazily)
as it's not normally preferable (see config proto documentation)
.
copts
:
client
.
ConnectionOptions
{
DisableHealthCheck
:
true
},
}
if
cfg
.
ConnectionOptions
!=
nil
&&
cfg
.
ConnectionOptions
.
UseSystemCaBundle
{
certs
,
err
:=
x509
.
SystemCertPool
()
if
err
!=
nil
{
return
nil
,
err
}
ret
.
copts
.
TLS
=
&
tls
.
Config
{
RootCAs
:
certs
,
MinVersion
:
tls
.
VersionTLS12
,
if
cfg
.
ConnectionOptions
!=
nil
{
ret
.
copts
.
DisableHealthCheck
=
!
cfg
.
ConnectionOptions
.
EnableHealthCheck
if
cfg
.
ConnectionOptions
.
UseSystemCaBundle
{
certs
,
err
:=
x509
.
SystemCertPool
()
if
err
!=
nil
{
return
nil
,
err
}
ret
.
copts
.
TLS
=
&
tls
.
Config
{
RootCAs
:
certs
,
MinVersion
:
tls
.
VersionTLS12
,
}
}
}
return
ret
,
nil
...
...
This diff is collapsed.
Click to expand it.
backend/service/temporal/temporal_test.go
+
2
-
2
View file @
71565c5e
...
...
@@ -32,14 +32,14 @@ func TestNewClientWithConnectionOptions(t *testing.T) {
cfg
:=
&
temporalv1
.
Config
{
Host
:
"dns:///example.com"
,
Port
:
9233
,
ConnectionOptions
:
&
temporalv1
.
ConnectionOptions
{
UseSystemCaBundle
:
true
},
ConnectionOptions
:
&
temporalv1
.
ConnectionOptions
{
UseSystemCaBundle
:
true
,
EnableHealthCheck
:
true
},
}
c
,
err
:=
newClient
(
cfg
,
zap
.
NewNop
(),
tally
.
NoopScope
)
assert
.
NoError
(
t
,
err
)
impl
:=
c
.
(
*
clientImpl
)
assert
.
NotNil
(
t
,
impl
.
copts
.
TLS
.
RootCAs
)
assert
.
Tru
e
(
t
,
impl
.
copts
.
DisableHealthCheck
)
assert
.
Fals
e
(
t
,
impl
.
copts
.
DisableHealthCheck
)
}
func
TestGetNamespaceClient
(
t
*
testing
.
T
)
{
...
...
This diff is collapsed.
Click to expand it.
frontend/api/src/index.d.ts
+
6
-
0
View file @
71565c5e
...
...
@@ -10164,6 +10164,9 @@ export namespace clutch {
/** ConnectionOptions useSystemCaBundle */
useSystemCaBundle?: (boolean|null);
/** ConnectionOptions enableHealthCheck */
enableHealthCheck?: (boolean|null);
}
/** Represents a ConnectionOptions. */
...
...
@@ -10178,6 +10181,9 @@ export namespace clutch {
/** ConnectionOptions useSystemCaBundle. */
public useSystemCaBundle: boolean;
/** ConnectionOptions enableHealthCheck. */
public enableHealthCheck: boolean;
/**
* Verifies a ConnectionOptions message.
* @param message Plain object to verify
This diff is collapsed.
Click to expand it.
frontend/api/src/index.js
+
19
-
1
View file @
71565c5e
...
...
@@ -24704,6 +24704,7 @@ export const clutch = $root.clutch = (() => {
* @memberof clutch.config.service.temporal.v1
* @interface IConnectionOptions
* @property {boolean|null} [useSystemCaBundle] ConnectionOptions useSystemCaBundle
* @property {boolean|null} [enableHealthCheck] ConnectionOptions enableHealthCheck
*/
/**
...
...
@@ -24729,6 +24730,14 @@ export const clutch = $root.clutch = (() => {
*/
ConnectionOptions.prototype.useSystemCaBundle = false;
/**
* ConnectionOptions enableHealthCheck.
* @member {boolean} enableHealthCheck
* @memberof clutch.config.service.temporal.v1.ConnectionOptions
* @instance
*/
ConnectionOptions.prototype.enableHealthCheck = false;
/**
* Verifies a ConnectionOptions message.
* @function verify
...
...
@@ -24743,6 +24752,9 @@ export const clutch = $root.clutch = (() => {
if (message.useSystemCaBundle != null && message.hasOwnProperty("useSystemCaBundle"))
if (typeof message.useSystemCaBundle !== "boolean")
return "useSystemCaBundle: boolean expected";
if (message.enableHealthCheck != null && message.hasOwnProperty("enableHealthCheck"))
if (typeof message.enableHealthCheck !== "boolean")
return "enableHealthCheck: boolean expected";
return null;
};
...
...
@@ -24760,6 +24772,8 @@ export const clutch = $root.clutch = (() => {
let message = new $root.clutch.config.service.temporal.v1.ConnectionOptions();
if (object.useSystemCaBundle != null)
message.useSystemCaBundle = Boolean(object.useSystemCaBundle);
if (object.enableHealthCheck != null)
message.enableHealthCheck = Boolean(object.enableHealthCheck);
return message;
};
...
...
@@ -24776,10 +24790,14 @@ export const clutch = $root.clutch = (() => {
if (!options)
options = {};
let object = {};
if (options.defaults)
if (options.defaults)
{
object.useSystemCaBundle = false;
object.enableHealthCheck = false;
}
if (message.useSystemCaBundle != null && message.hasOwnProperty("useSystemCaBundle"))
object.useSystemCaBundle = message.useSystemCaBundle;
if (message.enableHealthCheck != null && message.hasOwnProperty("enableHealthCheck"))
object.enableHealthCheck = message.enableHealthCheck;
return object;
};
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help