Skip to content

Commit

Permalink
feat(PortForwarder): Show Connection Count (#835)
Browse files Browse the repository at this point in the history
* feat(PortForwarder): Show Connection Count

* Update cicd.yml

* Update cicd.yml
  • Loading branch information
IvanJosipovic authored Dec 19, 2024
1 parent c3eb7f1 commit 937351d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ jobs:
with:
submodules: 'true'

- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x.x'

- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
Expand Down
6 changes: 6 additions & 0 deletions src/KubeUI/Client/PortForwarder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public partial class PortForwarder : ObservableObject, IEquatable<PortForwarder>
[ObservableProperty]
public partial string Status { get; set; } = "Initializing";

[ObservableProperty]
public partial int Connections { get; set; }

private bool _isDisposing;

public PortForwarder(ICluster cluster, string @namespace, int localPort = 0)
Expand Down Expand Up @@ -80,6 +83,7 @@ private void ClientConnected(IAsyncResult result)

private async Task HandleConnection(Socket socket)
{
Connections++;
var podName = Name;
var podPort = Port;
if (Type == "Service")
Expand All @@ -102,6 +106,7 @@ private async Task HandleConnection(Socket socket)
{
Status = "No pods found for Service";
socket.Close();
Connections--;
return;
}
else
Expand Down Expand Up @@ -151,6 +156,7 @@ private async Task HandleConnection(Socket socket)
await write;

socket.Close();
Connections--;
}

private static bool IsPortAvailable(int port)
Expand Down
6 changes: 6 additions & 0 deletions src/KubeUI/Views/Workloads/Pod/PortForwarderListView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ protected override object Build(PortForwarderListViewModel? vm)
{
Binding = new Binding(nameof(PortForwarder.Name)),
Header = "Name",
Width = new DataGridLength(1, DataGridLengthUnitType.Star),
},
new DataGridTextColumn()
{
Expand All @@ -43,6 +44,11 @@ protected override object Build(PortForwarderListViewModel? vm)
Header = "Local Port",
},
new DataGridTextColumn()
{
Binding = new Binding(nameof(PortForwarder.Connections)),
Header = "Connections",
},
new DataGridTextColumn()
{
Binding = new Binding(nameof(PortForwarder.Status)),
Header = "Status",
Expand Down

0 comments on commit 937351d

Please sign in to comment.