Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion SW.Bitween.Api/Resources/DataSources/Get.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using SW.Bitween.Domain;
using SW.Bitween.Domain.DataSources;
using SW.Bitween.Domain.Gateway;
using SW.Bitween.Model;
Expand Down Expand Up @@ -47,7 +48,9 @@ public async Task<object> Handle(int key)
OwnedByNode = dataSource.OwnedByNode,

GatewayCount = await dbContext.Set<BusGateway>()
.CountAsync(gateway => gateway.DataSourceId == key)
.CountAsync(gateway => gateway.DataSourceId == key),
SubscriptionCount = await dbContext.Set<Subscription>()
.CountAsync(subscription => subscription.DataSourceId == key)
};
}
}
5 changes: 4 additions & 1 deletion SW.Bitween.Api/Resources/DataSources/Search.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using SW.Bitween.Domain;
using SW.Bitween.Domain.DataSources;
using SW.Bitween.Domain.Gateway;
using SW.Bitween.Model;
Expand Down Expand Up @@ -41,7 +42,9 @@ public async Task<object> Handle(SearchyRequest searchyRequest, bool lookup = fa
// A correlated count, so the "used by" column costs one subquery per row rather
// than the whole BusGateway table over the wire.
GatewayCount = dbContext.Set<BusGateway>()
.Count(gateway => gateway.DataSourceId == dataSource.Id)
.Count(gateway => gateway.DataSourceId == dataSource.Id),
SubscriptionCount = dbContext.Set<Subscription>()
.Count(subscription => subscription.DataSourceId == dataSource.Id)
};

query = query.AsNoTracking();
Expand Down
3 changes: 3 additions & 0 deletions SW.Bitween.Sdk/Model/DataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public class DataSourceRow : DataSourceUpdate
/// <summary>How many bus gateways this data source feeds. Deleting is refused while any do.</summary>
public int GatewayCount { get; set; }

/// <summary>How many subscriptions run on this data source's connection.</summary>
public int SubscriptionCount { get; set; }

// ------------------------------------------------------------------ health

/// <summary>Null until the supervisor has reported on it once.</summary>
Expand Down
4 changes: 4 additions & 0 deletions SW.Bitween.Web/ClientApp/src/api/http/dataSources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ interface RawDataSource {
name: string;
adapterId: string;
kind: string;
placement?: string | null;
inactive: boolean | null;
deduplicationWindowDays: number;
softMemoryLimitMb?: number | null;
hardMemoryLimitMb?: number | null;
cpuPercentLimit?: number | null;
cpuLimitSamples?: number | null;
gatewayCount: number;
subscriptionCount?: number | null;
lastKnownState: string | null;
lastHeartbeatOn: string | null;
lastException: string | null;
Expand Down Expand Up @@ -54,13 +56,15 @@ const toRow = (raw: RawDataSource): DataSourceRow => ({
name: raw.name,
adapterId: raw.adapterId,
kind: raw.kind,
placement: raw.placement ?? "Auto",
inactive: raw.inactive ?? false,
deduplicationWindowDays: raw.deduplicationWindowDays,
softMemoryLimitMb: raw.softMemoryLimitMb ?? 0,
hardMemoryLimitMb: raw.hardMemoryLimitMb ?? 0,
cpuPercentLimit: raw.cpuPercentLimit ?? 0,
cpuLimitSamples: raw.cpuLimitSamples ?? 0,
gatewayCount: raw.gatewayCount,
subscriptionCount: raw.subscriptionCount ?? 0,
lastKnownState: raw.lastKnownState,
lastHeartbeatOn: raw.lastHeartbeatOn,
lastException: raw.lastException,
Expand Down
4 changes: 4 additions & 0 deletions SW.Bitween.Web/ClientApp/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,8 @@ export interface DataSource {
/** The adapter that speaks this protocol, e.g. bitween.bus.rabbitmq. */
adapterId: string;
kind: string;
/** Auto, Exclusive or PerNode. Auto means Exclusive for a broker and PerNode otherwise. */
placement: string;
inactive: boolean;
/**
* How long a message's deduplication key is remembered. Has to exceed the widest redelivery
Expand Down Expand Up @@ -845,6 +847,8 @@ export interface DataSource {
export interface DataSourceRow extends DataSource {
/** How many bus gateways read from it. Deleting is refused while any do. */
gatewayCount: number;
/** How many subscriptions run on its connection. */
subscriptionCount: number;
}

export interface DataSourceDetail extends DataSourceRow {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export function ConnectionBadge({
</Badge>
);

const tone = /connected|idle|running/i.test(state)
// Whole words, or "Disconnected" would match "connected" and read as healthy.
const tone = /\b(connected|ready|idle|running)\b/i.test(state)
? "ok"
: /starting|draining/i.test(state)
? "warn"
Expand Down
Loading
Loading