Skip to content

Commit

Permalink
Add env var to disable workflow count refresh (#2312)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Tideman authored Sep 24, 2024
1 parent ec72f61 commit ad81582
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 32 deletions.
1 change: 1 addition & 0 deletions server/config/development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ workflowResetDisabled: false
batchActionsDisabled: false
startWorkflowDisabled: false
hideWorkflowQueryErrors: false
refreshWorkflowCountsDisabled: false
auth:
enabled: false
providers:
Expand Down
1 change: 1 addition & 0 deletions server/docker/config-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ workflowResetDisabled: {{ default .Env.TEMPORAL_WORKFLOW_RESET_DISABLED "false"
batchActionsDisabled: {{ default .Env.TEMPORAL_BATCH_ACTIONS_DISABLED "false" }}
startWorkflowDisabled: {{ default .Env.TEMPORAL_START_WORKFLOW_DISABLED "true" }}
hideWorkflowQueryErrors: {{ default .Env.TEMPORAL_HIDE_WORKFLOW_QUERY_ERRORS "false" }}
refreshWorkflowCountsDisabled: {{ default .Env.TEMPORAL_REFRESH_WORKFLOW_COUNTS_DISABLED "false" }}
cors:
cookieInsecure: {{ default .Env.TEMPORAL_CSRF_COOKIE_INSECURE "false" }}
allowOrigins:
Expand Down
52 changes: 27 additions & 25 deletions server/server/api/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,23 @@ type CodecResponse struct {
}

type SettingsResponse struct {
Auth *Auth
BannerText string
DefaultNamespace string
ShowTemporalSystemNamespace bool
FeedbackURL string
NotifyOnNewVersion bool
Codec *CodecResponse
Version string
DisableWriteActions bool
WorkflowTerminateDisabled bool
WorkflowCancelDisabled bool
WorkflowSignalDisabled bool
WorkflowResetDisabled bool
BatchActionsDisabled bool
StartWorkflowDisabled bool
HideWorkflowQueryErrors bool
Auth *Auth
BannerText string
DefaultNamespace string
ShowTemporalSystemNamespace bool
FeedbackURL string
NotifyOnNewVersion bool
Codec *CodecResponse
Version string
DisableWriteActions bool
WorkflowTerminateDisabled bool
WorkflowCancelDisabled bool
WorkflowSignalDisabled bool
WorkflowResetDisabled bool
BatchActionsDisabled bool
StartWorkflowDisabled bool
HideWorkflowQueryErrors bool
RefreshWorkflowCountsDisabled bool
}

func TemporalAPIHandler(cfgProvider *config.ConfigProviderWithRefresh, apiMiddleware []Middleware, conn *grpc.ClientConn) echo.HandlerFunc {
Expand Down Expand Up @@ -136,15 +137,16 @@ func GetSettings(cfgProvider *config.ConfigProviderWithRefresh) func(echo.Contex
PassAccessToken: cfg.Codec.PassAccessToken,
IncludeCredentials: cfg.Codec.IncludeCredentials,
},
Version: version.UIVersion,
DisableWriteActions: cfg.DisableWriteActions,
WorkflowTerminateDisabled: cfg.WorkflowTerminateDisabled,
WorkflowCancelDisabled: cfg.WorkflowCancelDisabled,
WorkflowSignalDisabled: cfg.WorkflowSignalDisabled,
WorkflowResetDisabled: cfg.WorkflowResetDisabled,
BatchActionsDisabled: cfg.BatchActionsDisabled,
StartWorkflowDisabled: cfg.StartWorkflowDisabled,
HideWorkflowQueryErrors: cfg.HideWorkflowQueryErrors,
Version: version.UIVersion,
DisableWriteActions: cfg.DisableWriteActions,
WorkflowTerminateDisabled: cfg.WorkflowTerminateDisabled,
WorkflowCancelDisabled: cfg.WorkflowCancelDisabled,
WorkflowSignalDisabled: cfg.WorkflowSignalDisabled,
WorkflowResetDisabled: cfg.WorkflowResetDisabled,
BatchActionsDisabled: cfg.BatchActionsDisabled,
StartWorkflowDisabled: cfg.StartWorkflowDisabled,
HideWorkflowQueryErrors: cfg.HideWorkflowQueryErrors,
RefreshWorkflowCountsDisabled: cfg.RefreshWorkflowCountsDisabled,
}

return c.JSON(http.StatusOK, settings)
Expand Down
2 changes: 2 additions & 0 deletions server/server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ type (
StartWorkflowDisabled bool `yaml:"startWorkflowDisabled"`
// Whether to hide server errors for workflow queries in UI
HideWorkflowQueryErrors bool `yaml:"hideWorkflowQueryErrors"`
// Whether to disable refreshing workflow counts in UI
RefreshWorkflowCountsDisabled bool `yaml:"refreshWorkflowCountsDisabled"`
// Forward specified HTTP headers from HTTP API requests to Temporal gRPC backend
ForwardHeaders []string `yaml:"forwardHeaders"`
HideLogs bool `yaml:"hideLogs"`
Expand Down
17 changes: 10 additions & 7 deletions src/lib/components/workflow/workflow-counts.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import { workflowFilters } from '$lib/stores/filters';
import { currentPageKey } from '$lib/stores/pagination';
import {
disableWorkflowCountsRefresh,
queryWithParentWorkflowId,
refresh,
workflowCount,
Expand Down Expand Up @@ -102,13 +103,15 @@
const fetchCounts = async () => {
clearNewCounts();
const interval =
getExponentialBackoffSeconds(
initialIntervalSeconds,
attempt,
maxAttempts,
) * 1000;
refreshInterval = setInterval(() => fetchNewCounts(), interval);
if (!$disableWorkflowCountsRefresh) {
const interval =
getExponentialBackoffSeconds(
initialIntervalSeconds,
attempt,
maxAttempts,
) * 1000;
refreshInterval = setInterval(() => fetchNewCounts(), interval);
}
try {
const { count, groups } = await fetchWorkflowCountByExecutionStatus({
namespace,
Expand Down
3 changes: 3 additions & 0 deletions src/lib/services/settings-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export const fetchSettings = async (request = fetch): Promise<Settings> => {
batchActionsDisabled: !!settingsResponse?.BatchActionsDisabled,
startWorkflowDisabled: !!settingsResponse?.StartWorkflowDisabled,
hideWorkflowQueryErrors: !!settingsResponse?.HideWorkflowQueryErrors,
refreshWorkflowCountsDisabled:
!!settingsResponse?.RefreshWorkflowCountsDisabled,

showTemporalSystemNamespace: settingsResponse?.ShowTemporalSystemNamespace,
notifyOnNewVersion: settingsResponse?.NotifyOnNewVersion,
feedbackURL: settingsResponse?.FeedbackURL,
Expand Down
5 changes: 5 additions & 0 deletions src/lib/stores/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export const hideWorkflowQueryErrors = derived(
([$page]) => $page.data?.settings?.hideWorkflowQueryErrors,
);

export const disableWorkflowCountsRefresh = derived(
[page],
([$page]) => $page.data?.settings?.refreshWorkflowCountsDisabled,
);

export const canFetchChildWorkflows = derived(
[isCloud, temporalVersion],
([$isCloud, $temporalVersion]) => {
Expand Down
1 change: 1 addition & 0 deletions src/lib/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export type SettingsResponse = {
BatchActionsDisabled: boolean;
StartWorkflowDisabled: boolean;
HideWorkflowQueryErrors: boolean;
RefreshWorkflowCountsDisabled: boolean;
ShowTemporalSystemNamespace: boolean;
NotifyOnNewVersion: boolean;
FeedbackURL: string;
Expand Down
1 change: 1 addition & 0 deletions tests/test-utilities/mocks/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const defaultSettings = {
StartWorkflowDisabled: true,
BatchActionsDisabled: false,
HideWorkflowQueryErrors: false,
RefreshWorkflowCountsDisabled: false,
};

export const mockSettingsApi = async (
Expand Down

0 comments on commit ad81582

Please sign in to comment.