Skip to content

Commit

Permalink
Added defaults to all fields
Browse files Browse the repository at this point in the history
  • Loading branch information
danyi1212 committed Dec 16, 2023
1 parent c19917f commit edcc9ca
Show file tree
Hide file tree
Showing 15 changed files with 130 additions and 104 deletions.
18 changes: 9 additions & 9 deletions frontend/src/components/worker/panels/BrokerDetailsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const BrokerDetailsCard: React.FC<BrokerDetailsCardProps> = ({ hostname, ...prop
label="Hostname"
value={
<Box display="flex" alignItems="center">
{stats?.broker.hostname}
<Tooltip title={stats?.broker.ssl ? "SSL Enabled" : "SSL Disabled"} describeChild>
{stats?.broker.ssl ? (
{stats?.broker?.hostname}
<Tooltip title={stats?.broker?.ssl ? "SSL Enabled" : "SSL Disabled"} describeChild>
{stats?.broker?.ssl ? (
<LockIcon fontSize="small" color="success" sx={{ mx: 1 }} />
) : (
<LockOpenIcon fontSize="small" color="error" sx={{ mx: 1 }} />
Expand All @@ -36,25 +36,25 @@ const BrokerDetailsCard: React.FC<BrokerDetailsCardProps> = ({ hostname, ...prop
/>
</Grid>
<Grid item xs={12} md={6}>
<DetailItem label="Port" value={stats?.broker.port} />
<DetailItem label="Port" value={stats?.broker?.port} />
</Grid>
<Grid item xs={12} md={6}>
<DetailItem label="Transport" value={stats?.broker.transport} />
<DetailItem label="Transport" value={stats?.broker?.transport} />
</Grid>
<Grid item xs={12} md={6}>
<DetailItem label="User ID" value={stats?.broker.userid} />
<DetailItem label="User ID" value={stats?.broker?.userid} />
</Grid>
<Grid item xs={12} md={6}>
<DetailItem label="Timeout" value={stats?.broker.connection_timeout ?? "Unlimited"} />
<DetailItem label="Timeout" value={stats?.broker?.connection_timeout ?? "Unlimited"} />
</Grid>
<Grid item xs={12} md={6}>
<DetailItem
label="Heartbeat Interval"
value={formatSecondsDuration(stats?.broker.heartbeat || 0)}
value={formatSecondsDuration(stats?.broker?.heartbeat || 0)}
/>
</Grid>
<Grid item xs={12} md={6}>
<DetailItem label="Login Method" value={stats?.broker.login_method} />
<DetailItem label="Login Method" value={stats?.broker?.login_method} />
</Grid>
</Grid>
</Panel>
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/worker/panels/PoolDetailsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,25 @@ const PoolDetailsCard: React.FC<PoolDetailsCardProps> = ({ hostname, ...props })
<DetailItem
label="Max Concurrency"
description="Maximum number of child parallelism (processes/threads)"
value={stats?.pool["max-concurrency"]}
value={stats?.pool?.["max-concurrency"] || "Unknown"}
/>
</Grid>
<Grid item xs={12} md={6}>
<DetailItem
label="Recycle Limit"
description="Maximum number of tasks to be executed before child recycled"
value={stats?.pool["max-tasks-per-child"]}
value={stats?.pool?.["max-tasks-per-child"] || "Unknown"}
/>
</Grid>
<Grid item xs={12} md={6}>
<DetailItem label="Soft Timeout" value={formatSecondsDuration(stats?.pool.timeouts[0] || 0)} />
<DetailItem label="Soft Timeout" value={formatSecondsDuration(stats?.pool?.timeouts?.[0] || 0)} />
</Grid>
<Grid item xs={12} md={6}>
<DetailItem label="Hard Timeout" value={formatSecondsDuration(stats?.pool.timeouts[1] || 0)} />
<DetailItem label="Hard Timeout" value={formatSecondsDuration(stats?.pool?.timeouts?.[1] || 0)} />
</Grid>
<Grid item xs={12}>
<Grid container direction="row" spacing={0.5}>
{stats?.pool.processes.map((process) => (
{stats?.pool?.processes?.map((process) => (
<Grid item key={process} xs={3}>
<ProcessChip processId={process} task={taskProcessMap.get(process)} />
</Grid>
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/worker/panels/QueueDetailsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ interface QueueDetailsPanelProps {

const QueueDetailsPanel: React.FC<QueueDetailsPanelProps> = ({ queue }) => {
return (
<Panel title={queue.name} sx={{ px: 2 }} elevation={10}>
{queue.exchange.name !== queue.routing_key ? (
<Panel title={queue.name || "Unknown"} sx={{ px: 2 }} elevation={10}>
{queue?.exchange?.name !== queue.routing_key ? (
<DetailItem
label="Exchange"
description="The name of the exchange that the queue is bound to"
value={queue.exchange.name}
value={queue?.exchange?.name || "Unknown"}
/>
) : null}
<DetailItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const RegisteredTasksPanel: React.FC<RegisteredTasksPanelProps> = ({ workerId, h
key={taskType}
taskType={taskType}
workerId={workerId}
count={stats?.total[taskType]}
count={stats?.total?.[taskType]}
/>
))}
</List>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ interface ReservedTaskListItemProps {
}

const ReservedTaskListItem: React.FC<ReservedTaskListItemProps> = ({ task }) => {
return <TaskListItem task={task} subtitle={"Routing key: " + task.delivery_info.routing_key} />
return <TaskListItem task={task} subtitle={"Routing key: " + task.delivery_info?.routing_key} />
}
export default ReservedTaskListItem
2 changes: 1 addition & 1 deletion frontend/src/services/demo/services/DemoWorkersService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class DemoWorkersService {
},
pool: {
"max-concurrency": 16,
"max-tasks-per-child": "N/A",
"max-tasks-per-child": 0,
processes: fakePIDs,
timeouts: [1740, 1800],
"put-guarded-by-semaphore": false,
Expand Down
18 changes: 9 additions & 9 deletions frontend/src/services/server/models/Broker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,42 @@ export type Broker = {
/**
* Heartbeat interval in seconds
*/
heartbeat: number;
heartbeat?: number;
/**
* Node name of remote broker
*/
hostname: string;
hostname?: (string | null);
/**
* Login method used to connect to the broker
*/
login_method: string;
login_method?: (string | null);
/**
* Broker port
*/
port: number;
port?: number;
/**
* Whether to use ssl connections
*/
ssl: boolean;
ssl?: boolean;
/**
* Name of transport used (e.g, amqp / redis)
*/
transport: string;
transport?: (string | null);
/**
* Additional options used to connect to broker
*/
transport_options: Record<string, any>;
transport_options?: Record<string, any>;
/**
* Prefix to be added to broker uri
*/
uri_prefix?: (string | null);
/**
* User ID used to connect to the broker with
*/
userid: string;
userid?: (string | null);
/**
* Virtual host used
*/
virtual_host: string;
virtual_host?: (string | null);
};

6 changes: 3 additions & 3 deletions frontend/src/services/server/models/DeliveryInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ export type DeliveryInfo = {
/**
* Broker exchange used
*/
exchange: string;
exchange?: (string | null);
/**
* Message priority
*/
priority?: (number | null);
/**
* Message sent back to queue
*/
redelivered: boolean;
redelivered?: boolean;
/**
* Message routing key used
*/
routing_key: string;
routing_key?: (string | null);
};

4 changes: 2 additions & 2 deletions frontend/src/services/server/models/ExchangeInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ export type ExchangeInfo = {
/**
* Name of exchange
*/
name: string;
name?: (string | null);
/**
* Exchange routing type
*/
type: string;
type?: (string | null);
};

8 changes: 4 additions & 4 deletions frontend/src/services/server/models/Pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ export type Pool = {
/**
* Maximum number of child parallelism (processes/threads)
*/
'max-concurrency': number;
'max-concurrency'?: number;
/**
* Maximum number of tasks to be executed before child recycled
*/
'max-tasks-per-child': (number | string);
'max-tasks-per-child'?: number;
/**
* Child process IDs (or thread IDs)
*/
processes: Array<number>;
processes?: Array<number>;
/**
* Soft time limit and hard time limit, in seconds
*/
timeouts: any[];
timeouts?: any[];
};

14 changes: 7 additions & 7 deletions frontend/src/services/server/models/QueueInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ export type QueueInfo = {
/**
* Name of the queue
*/
name: string;
name?: (string | null);
/**
* Exchange information
*/
exchange: ExchangeInfo;
exchange?: ExchangeInfo;
/**
* Routing key for the queue
*/
routing_key: string;
routing_key?: (string | null);
/**
* Arguments for the queue
*/
Expand All @@ -33,19 +33,19 @@ export type QueueInfo = {
/**
* Queue will survive broker restart
*/
durable: boolean;
durable?: boolean;
/**
* Queue can be used by only one consumer
*/
exclusive: boolean;
exclusive?: boolean;
/**
* Queue will be deleted after last consumer unsubscribes
*/
auto_delete: boolean;
auto_delete?: boolean;
/**
* Workers will not acknowledge task messages
*/
no_ack: boolean;
no_ack?: boolean;
/**
* Queue alias if used for queue names
*/
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/services/server/models/ServerInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
/* tslint:disable */
/* eslint-disable */

import type { CPULoad } from './CPULoad';

export type ServerInfo = {
cpu_usage: any[];
/**
* CPU load average in last 1, 5 and 15 minutes
*/
cpu_usage: CPULoad;
/**
* Memory Usage in KB
*/
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/services/server/models/Stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type Stats = {
/**
* Current broker stats
*/
broker: Broker;
broker?: Broker;
/**
* Current logical clock time
*/
Expand All @@ -26,18 +26,18 @@ export type Stats = {
/**
* Current pool stats
*/
pool: Pool;
pool?: Pool;
/**
* Current prefetch task queue for consumer
*/
prefetch_count: number;
/**
* Operating System statistics
*/
rusage: Record<string, any>;
rusage?: Record<string, any>;
/**
* Count of accepted tasks by type
*/
total: Record<string, number>;
total?: Record<string, number>;
};

4 changes: 2 additions & 2 deletions frontend/src/services/server/models/TaskRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ export type TaskRequest = {
/**
* Delivery Information about the task Message
*/
delivery_info: DeliveryInfo;
delivery_info?: DeliveryInfo;
/**
* Whether the task message is acknowledged
*/
acknowledged: boolean;
acknowledged?: boolean;
/**
* When the task has started by the worker
*/
Expand Down
Loading

0 comments on commit edcc9ca

Please sign in to comment.