Skip to content

Instantly share code, notes, and snippets.

@smdn
Created May 22, 2023 12:27
Show Gist options
  • Save smdn/e88ab1cb66cf699d658f8f44be5c6645 to your computer and use it in GitHub Desktop.
Save smdn/e88ab1cb66cf699d658f8f44be5c6645 to your computer and use it in GitHub Desktop.
Smdn.Net.MuninNode 1.1.0 Release Notes
diff --git a/doc/api-list/Smdn.Net.MuninNode/Smdn.Net.MuninNode-net6.0.apilist.cs b/doc/api-list/Smdn.Net.MuninNode/Smdn.Net.MuninNode-net6.0.apilist.cs
index 3edc58c..421f9f1 100644
--- a/doc/api-list/Smdn.Net.MuninNode/Smdn.Net.MuninNode-net6.0.apilist.cs
+++ b/doc/api-list/Smdn.Net.MuninNode/Smdn.Net.MuninNode-net6.0.apilist.cs
@@ -1,188 +1,188 @@
-// Smdn.Net.MuninNode.dll (Smdn.Net.MuninNode-1.0.0)
+// Smdn.Net.MuninNode.dll (Smdn.Net.MuninNode-1.1.0)
// Name: Smdn.Net.MuninNode
-// AssemblyVersion: 1.0.0.0
-// InformationalVersion: 1.0.0+37a9c6955012b57d019d2c68b8fa9876540f0263
+// AssemblyVersion: 1.1.0.0
+// InformationalVersion: 1.1.0+8c512e91195981258988a30fdf9c0ff4c53a6acc
// TargetFramework: .NETCoreApp,Version=v6.0
// Configuration: Release
// Referenced assemblies:
// Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
// Microsoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
// Smdn.Fundamental.Exception, Version=3.0.0.0, Culture=neutral
// System.Collections, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// System.ComponentModel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// System.IO.Pipelines, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
// System.Linq, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// System.Memory, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
// System.Net.Primitives, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// System.Net.Sockets, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// System.Security.Cryptography.Algorithms, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// System.Text.RegularExpressions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
#nullable enable annotations
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Smdn.Net.MuninNode;
using Smdn.Net.MuninPlugin;
namespace Smdn.Net.MuninNode {
public class LocalNode : NodeBase {
public LocalNode(IReadOnlyCollection<IPlugin> plugins, int port, IServiceProvider? serviceProvider = null) {}
public LocalNode(IReadOnlyCollection<IPlugin> plugins, string hostName, int port, IServiceProvider? serviceProvider = null) {}
public IPEndPoint LocalEndPoint { get; }
protected override Socket CreateServerSocket() {}
protected override bool IsClientAcceptable(IPEndPoint remoteEndPoint) {}
}
public abstract class NodeBase :
IAsyncDisposable,
IDisposable
{
- public NodeBase(IReadOnlyCollection<IPlugin> plugins, string hostName, ILogger? logger) {}
+ protected NodeBase(IReadOnlyCollection<IPlugin> plugins, string hostName, ILogger? logger) {}
public virtual Encoding Encoding { get; }
public string HostName { get; }
public virtual Version NodeVersion { get; }
public IReadOnlyCollection<IPlugin> Plugins { get; }
public async ValueTask AcceptAsync(bool throwIfCancellationRequested, CancellationToken cancellationToken) {}
public async ValueTask AcceptSingleSessionAsync(CancellationToken cancellationToken = default) {}
protected abstract Socket CreateServerSocket();
protected virtual void Dispose(bool disposing) {}
public void Dispose() {}
public async ValueTask DisposeAsync() {}
protected virtual async ValueTask DisposeAsyncCore() {}
protected abstract bool IsClientAcceptable(IPEndPoint remoteEndPoint);
public void Start() {}
}
}
namespace Smdn.Net.MuninPlugin {
public interface INodeSessionCallback {
ValueTask ReportSessionClosedAsync(string sessionId, CancellationToken cancellationToken);
ValueTask ReportSessionStartedAsync(string sessionId, CancellationToken cancellationToken);
}
public interface IPlugin {
IPluginDataSource DataSource { get; }
PluginGraphAttributes GraphAttributes { get; }
string Name { get; }
INodeSessionCallback? SessionCallback { get; }
}
public interface IPluginDataSource {
IReadOnlyCollection<IPluginField> Fields { get; }
}
public interface IPluginField {
PluginFieldAttributes Attributes { get; }
string Name { get; }
ValueTask<string> GetFormattedValueStringAsync(CancellationToken cancellationToken);
}
public enum PluginFieldGraphStyle : int {
Area = 1,
AreaStack = 3,
Default = 0,
Line = 100,
LineStack = 200,
LineStackWidth1 = 201,
LineStackWidth2 = 202,
LineStackWidth3 = 203,
LineWidth1 = 101,
LineWidth2 = 102,
LineWidth3 = 103,
Stack = 2,
}
public class Plugin :
INodeSessionCallback,
IPlugin,
IPluginDataSource
{
public Plugin(string name, PluginGraphAttributes graphAttributes, IReadOnlyCollection<IPluginField> fields) {}
public IReadOnlyCollection<IPluginField> Fields { get; }
public PluginGraphAttributes GraphAttributes { get; }
public string Name { get; }
IPluginDataSource IPlugin.DataSource { get; }
INodeSessionCallback? IPlugin.SessionCallback { get; }
IReadOnlyCollection<IPluginField> IPluginDataSource.Fields { get; }
protected virtual ValueTask ReportSessionClosedAsync(string sessionId, CancellationToken cancellationToken) {}
protected virtual ValueTask ReportSessionStartedAsync(string sessionId, CancellationToken cancellationToken) {}
ValueTask INodeSessionCallback.ReportSessionClosedAsync(string sessionId, CancellationToken cancellationToken) {}
ValueTask INodeSessionCallback.ReportSessionStartedAsync(string sessionId, CancellationToken cancellationToken) {}
}
public static class PluginFactory {
public static IPluginField CreateField(string label, Func<double?> fetchValue) {}
public static IPluginField CreateField(string label, PluginFieldGraphStyle graphStyle, Func<double?> fetchValue) {}
public static IPluginField CreateField(string label, PluginFieldGraphStyle graphStyle, PluginFieldNormalValueRange normalRangeForWarning, PluginFieldNormalValueRange normalRangeForCritical, Func<double?> fetchValue) {}
public static IPlugin CreatePlugin(string name, PluginGraphAttributes graphAttributes, IReadOnlyCollection<IPluginField> fields) {}
public static IPlugin CreatePlugin(string name, PluginGraphAttributes graphAttributes, IReadOnlyCollection<PluginFieldBase> fields) {}
public static IPlugin CreatePlugin(string name, PluginGraphAttributes graphAttributes, PluginFieldBase field) {}
public static IPlugin CreatePlugin(string name, string fieldLabel, Func<double?> fetchFieldValue, PluginGraphAttributes graphAttributes) {}
public static IPlugin CreatePlugin(string name, string fieldLabel, PluginFieldGraphStyle fieldGraphStyle, Func<double?> fetchFieldValue, PluginGraphAttributes graphAttributes) {}
}
public abstract class PluginFieldBase : IPluginField {
protected PluginFieldBase(string label, string? name, PluginFieldGraphStyle graphStyle = PluginFieldGraphStyle.Default, PluginFieldNormalValueRange normalRangeForWarning = default, PluginFieldNormalValueRange normalRangeForCritical = default) {}
public PluginFieldGraphStyle GraphStyle { get; }
public string Label { get; }
public string Name { get; }
public PluginFieldNormalValueRange NormalRangeForCritical { get; }
public PluginFieldNormalValueRange NormalRangeForWarning { get; }
PluginFieldAttributes IPluginField.Attributes { get; }
protected abstract ValueTask<double?> FetchValueAsync(CancellationToken cancellationToken);
async ValueTask<string> IPluginField.GetFormattedValueStringAsync(CancellationToken cancellationToken) {}
}
public sealed class PluginGraphAttributes {
public PluginGraphAttributes(string title, string category, string verticalLabel, bool scale, string arguments, TimeSpan updateRate, int? width = null, int? height = null) {}
public string Arguments { get; }
public string Category { get; }
public int? Height { get; }
public bool Scale { get; }
public string Title { get; }
public TimeSpan UpdateRate { get; }
public string VerticalLabel { get; }
public int? Width { get; }
}
public readonly struct PluginFieldAttributes {
public PluginFieldAttributes(string label, PluginFieldGraphStyle graphStyle = PluginFieldGraphStyle.Default) {}
public PluginFieldAttributes(string label, PluginFieldGraphStyle graphStyle = PluginFieldGraphStyle.Default, PluginFieldNormalValueRange normalRangeForWarning = default, PluginFieldNormalValueRange normalRangeForCritical = default) {}
public PluginFieldGraphStyle GraphStyle { get; }
public string Label { get; }
public PluginFieldNormalValueRange NormalRangeForCritical { get; }
public PluginFieldNormalValueRange NormalRangeForWarning { get; }
}
public readonly struct PluginFieldNormalValueRange {
public static readonly PluginFieldNormalValueRange None; // = "Smdn.Net.MuninPlugin.PluginFieldNormalValueRange"
public static PluginFieldNormalValueRange CreateMax(double max) {}
public static PluginFieldNormalValueRange CreateMin(double min) {}
public static PluginFieldNormalValueRange CreateRange(double min, double max) {}
public bool HasValue { get; }
public double? Max { get; }
public double? Min { get; }
}
}
-// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.2.1.0.
+// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.2.2.0.
// Smdn.Reflection.ReverseGenerating.ListApi.Core v1.2.0.0 (https://github.com/smdn/Smdn.Reflection.ReverseGenerating)
diff --git a/doc/api-list/Smdn.Net.MuninNode/Smdn.Net.MuninNode-netstandard2.1.apilist.cs b/doc/api-list/Smdn.Net.MuninNode/Smdn.Net.MuninNode-netstandard2.1.apilist.cs
index fd9a5e4..2b85970 100644
--- a/doc/api-list/Smdn.Net.MuninNode/Smdn.Net.MuninNode-netstandard2.1.apilist.cs
+++ b/doc/api-list/Smdn.Net.MuninNode/Smdn.Net.MuninNode-netstandard2.1.apilist.cs
@@ -1,181 +1,181 @@
-// Smdn.Net.MuninNode.dll (Smdn.Net.MuninNode-1.0.0)
+// Smdn.Net.MuninNode.dll (Smdn.Net.MuninNode-1.1.0)
// Name: Smdn.Net.MuninNode
-// AssemblyVersion: 1.0.0.0
-// InformationalVersion: 1.0.0+37a9c6955012b57d019d2c68b8fa9876540f0263
+// AssemblyVersion: 1.1.0.0
+// InformationalVersion: 1.1.0+8c512e91195981258988a30fdf9c0ff4c53a6acc
// TargetFramework: .NETStandard,Version=v2.1
// Configuration: Release
// Referenced assemblies:
// Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
// Microsoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
// Smdn.Fundamental.Encoding.Buffer, Version=3.0.0.0, Culture=neutral
// Smdn.Fundamental.Exception, Version=3.0.0.0, Culture=neutral
// System.IO.Pipelines, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
// netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
#nullable enable annotations
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Smdn.Net.MuninNode;
using Smdn.Net.MuninPlugin;
namespace Smdn.Net.MuninNode {
public class LocalNode : NodeBase {
public LocalNode(IReadOnlyCollection<IPlugin> plugins, int port, IServiceProvider? serviceProvider = null) {}
public LocalNode(IReadOnlyCollection<IPlugin> plugins, string hostName, int port, IServiceProvider? serviceProvider = null) {}
public IPEndPoint LocalEndPoint { get; }
protected override Socket CreateServerSocket() {}
protected override bool IsClientAcceptable(IPEndPoint remoteEndPoint) {}
}
public abstract class NodeBase :
IAsyncDisposable,
IDisposable
{
- public NodeBase(IReadOnlyCollection<IPlugin> plugins, string hostName, ILogger? logger) {}
+ protected NodeBase(IReadOnlyCollection<IPlugin> plugins, string hostName, ILogger? logger) {}
public virtual Encoding Encoding { get; }
public string HostName { get; }
public virtual Version NodeVersion { get; }
public IReadOnlyCollection<IPlugin> Plugins { get; }
public async ValueTask AcceptAsync(bool throwIfCancellationRequested, CancellationToken cancellationToken) {}
public async ValueTask AcceptSingleSessionAsync(CancellationToken cancellationToken = default) {}
protected abstract Socket CreateServerSocket();
protected virtual void Dispose(bool disposing) {}
public void Dispose() {}
public async ValueTask DisposeAsync() {}
protected virtual ValueTask DisposeAsyncCore() {}
protected abstract bool IsClientAcceptable(IPEndPoint remoteEndPoint);
public void Start() {}
}
}
namespace Smdn.Net.MuninPlugin {
public interface INodeSessionCallback {
ValueTask ReportSessionClosedAsync(string sessionId, CancellationToken cancellationToken);
ValueTask ReportSessionStartedAsync(string sessionId, CancellationToken cancellationToken);
}
public interface IPlugin {
IPluginDataSource DataSource { get; }
PluginGraphAttributes GraphAttributes { get; }
string Name { get; }
INodeSessionCallback? SessionCallback { get; }
}
public interface IPluginDataSource {
IReadOnlyCollection<IPluginField> Fields { get; }
}
public interface IPluginField {
PluginFieldAttributes Attributes { get; }
string Name { get; }
ValueTask<string> GetFormattedValueStringAsync(CancellationToken cancellationToken);
}
public enum PluginFieldGraphStyle : int {
Area = 1,
AreaStack = 3,
Default = 0,
Line = 100,
LineStack = 200,
LineStackWidth1 = 201,
LineStackWidth2 = 202,
LineStackWidth3 = 203,
LineWidth1 = 101,
LineWidth2 = 102,
LineWidth3 = 103,
Stack = 2,
}
public class Plugin :
INodeSessionCallback,
IPlugin,
IPluginDataSource
{
public Plugin(string name, PluginGraphAttributes graphAttributes, IReadOnlyCollection<IPluginField> fields) {}
public IReadOnlyCollection<IPluginField> Fields { get; }
public PluginGraphAttributes GraphAttributes { get; }
public string Name { get; }
IPluginDataSource IPlugin.DataSource { get; }
INodeSessionCallback? IPlugin.SessionCallback { get; }
IReadOnlyCollection<IPluginField> IPluginDataSource.Fields { get; }
protected virtual ValueTask ReportSessionClosedAsync(string sessionId, CancellationToken cancellationToken) {}
protected virtual ValueTask ReportSessionStartedAsync(string sessionId, CancellationToken cancellationToken) {}
ValueTask INodeSessionCallback.ReportSessionClosedAsync(string sessionId, CancellationToken cancellationToken) {}
ValueTask INodeSessionCallback.ReportSessionStartedAsync(string sessionId, CancellationToken cancellationToken) {}
}
public static class PluginFactory {
public static IPluginField CreateField(string label, Func<double?> fetchValue) {}
public static IPluginField CreateField(string label, PluginFieldGraphStyle graphStyle, Func<double?> fetchValue) {}
public static IPluginField CreateField(string label, PluginFieldGraphStyle graphStyle, PluginFieldNormalValueRange normalRangeForWarning, PluginFieldNormalValueRange normalRangeForCritical, Func<double?> fetchValue) {}
public static IPlugin CreatePlugin(string name, PluginGraphAttributes graphAttributes, IReadOnlyCollection<IPluginField> fields) {}
public static IPlugin CreatePlugin(string name, PluginGraphAttributes graphAttributes, IReadOnlyCollection<PluginFieldBase> fields) {}
public static IPlugin CreatePlugin(string name, PluginGraphAttributes graphAttributes, PluginFieldBase field) {}
public static IPlugin CreatePlugin(string name, string fieldLabel, Func<double?> fetchFieldValue, PluginGraphAttributes graphAttributes) {}
public static IPlugin CreatePlugin(string name, string fieldLabel, PluginFieldGraphStyle fieldGraphStyle, Func<double?> fetchFieldValue, PluginGraphAttributes graphAttributes) {}
}
public abstract class PluginFieldBase : IPluginField {
protected PluginFieldBase(string label, string? name, PluginFieldGraphStyle graphStyle = PluginFieldGraphStyle.Default, PluginFieldNormalValueRange normalRangeForWarning = default, PluginFieldNormalValueRange normalRangeForCritical = default) {}
public PluginFieldGraphStyle GraphStyle { get; }
public string Label { get; }
public string Name { get; }
public PluginFieldNormalValueRange NormalRangeForCritical { get; }
public PluginFieldNormalValueRange NormalRangeForWarning { get; }
PluginFieldAttributes IPluginField.Attributes { get; }
protected abstract ValueTask<double?> FetchValueAsync(CancellationToken cancellationToken);
async ValueTask<string> IPluginField.GetFormattedValueStringAsync(CancellationToken cancellationToken) {}
}
public sealed class PluginGraphAttributes {
public PluginGraphAttributes(string title, string category, string verticalLabel, bool scale, string arguments, TimeSpan updateRate, int? width = null, int? height = null) {}
public string Arguments { get; }
public string Category { get; }
public int? Height { get; }
public bool Scale { get; }
public string Title { get; }
public TimeSpan UpdateRate { get; }
public string VerticalLabel { get; }
public int? Width { get; }
}
public readonly struct PluginFieldAttributes {
public PluginFieldAttributes(string label, PluginFieldGraphStyle graphStyle = PluginFieldGraphStyle.Default) {}
public PluginFieldAttributes(string label, PluginFieldGraphStyle graphStyle = PluginFieldGraphStyle.Default, PluginFieldNormalValueRange normalRangeForWarning = default, PluginFieldNormalValueRange normalRangeForCritical = default) {}
public PluginFieldGraphStyle GraphStyle { get; }
public string Label { get; }
public PluginFieldNormalValueRange NormalRangeForCritical { get; }
public PluginFieldNormalValueRange NormalRangeForWarning { get; }
}
public readonly struct PluginFieldNormalValueRange {
public static readonly PluginFieldNormalValueRange None; // = "Smdn.Net.MuninPlugin.PluginFieldNormalValueRange"
public static PluginFieldNormalValueRange CreateMax(double max) {}
public static PluginFieldNormalValueRange CreateMin(double min) {}
public static PluginFieldNormalValueRange CreateRange(double min, double max) {}
public bool HasValue { get; }
public double? Max { get; }
public double? Min { get; }
}
}
-// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.2.1.0.
+// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.2.2.0.
// Smdn.Reflection.ReverseGenerating.ListApi.Core v1.2.0.0 (https://github.com/smdn/Smdn.Reflection.ReverseGenerating)
--- Smdn.Net.MuninNode.latest.nuspec
+++ Smdn.Net.MuninNode.1.1.0.nuspec
@@ -1,33 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
-<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
+<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>Smdn.Net.MuninNode</id>
- <version>1.0.0</version>
+ <version>1.1.0</version>
<title>Smdn.Net.MuninNode</title>
<authors>smdn</authors>
<license type="expression">MIT</license>
<licenseUrl>https://licenses.nuget.org/MIT</licenseUrl>
<icon>Smdn.Net.MuninNode.png</icon>
<readme>README.md</readme>
<projectUrl>https://github.com/smdn/Smdn.Net.MuninNode</projectUrl>
<description>A .NET implementation of [Munin-Node](http://guide.munin-monitoring.org/en/latest/node/index.html) and [Munin-Plugin](http://guide.munin-monitoring.org/en/latest/plugin/index.html). This library provides Munin-Node implementation for .NET, which enables to you to create custom Munin-Node using the .NET languages and libraries. This library also provides abstraction APIs for implementing Munin-Plugin. By using Munin-Plugin APIs in combination with the Munin-Node implementation, you can implement the function of collecting various kind of telemetry data using Munin, with .NET.</description>
+ <releaseNotes>https://github.com/smdn/Smdn.Net.MuninNode/releases/tag/releases%2FSmdn.Net.MuninNode-1.1.0</releaseNotes>
<copyright>Copyright © 2021 smdn</copyright>
<tags>smdn.jp Munin,Munin-Node,Munin-Plugin</tags>
- <repository type="git" url="https://github.com/smdn/Smdn.Net.MuninNode" branch="main" commit="37a9c6955012b57d019d2c68b8fa9876540f0263" />
+ <repository type="git" url="https://github.com/smdn/Smdn.Net.MuninNode" commit="8c512e91195981258988a30fdf9c0ff4c53a6acc" />
<dependencies>
<group targetFramework="net6.0">
<dependency id="Microsoft.Extensions.DependencyInjection.Abstractions" version="6.0.0" exclude="Build,Analyzers" />
<dependency id="Microsoft.Extensions.Logging.Abstractions" version="6.0.0" exclude="Build,Analyzers" />
<dependency id="Smdn.Fundamental.Exception" version="[3.0.0, 4.0.0)" exclude="Build,Analyzers" />
<dependency id="System.IO.Pipelines" version="6.0.0" exclude="Build,Analyzers" />
</group>
<group targetFramework=".NETStandard2.1">
<dependency id="Microsoft.Extensions.DependencyInjection.Abstractions" version="6.0.0" exclude="Build,Analyzers" />
<dependency id="Microsoft.Extensions.Logging.Abstractions" version="6.0.0" exclude="Build,Analyzers" />
<dependency id="Smdn.Fundamental.Encoding.Buffer" version="[3.0.0, 4.0.0)" exclude="Build,Analyzers" />
<dependency id="Smdn.Fundamental.Exception" version="[3.0.0, 4.0.0)" exclude="Build,Analyzers" />
<dependency id="System.IO.Pipelines" version="6.0.0" exclude="Build,Analyzers" />
</group>
</dependencies>
</metadata>
</package>
\ No newline at end of file
diff --git a/src/Smdn.Net.MuninNode/Smdn.Net.MuninNode.csproj b/src/Smdn.Net.MuninNode/Smdn.Net.MuninNode.csproj
index 182b3a4..ce3c7a3 100644
--- a/src/Smdn.Net.MuninNode/Smdn.Net.MuninNode.csproj
+++ b/src/Smdn.Net.MuninNode/Smdn.Net.MuninNode.csproj
@@ -5,9 +5,10 @@ SPDX-License-Identifier: MIT
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.1;net6.0</TargetFrameworks>
- <VersionPrefix>1.0.0</VersionPrefix>
+ <VersionPrefix>1.1.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
- <!-- <PackageValidationBaselineVersion>1.0.0</PackageValidationBaselineVersion> -->
+ <PackageValidationBaselineVersion>1.0.0</PackageValidationBaselineVersion>
+ <RootNamespace/> <!-- empty the root namespace so that the namespace is determined only by the directory name, for code style rule IDE0030 -->
<Nullable>enable</Nullable>
<DefineConstants
Condition="$([MSBuild]::VersionGreaterThanOrEquals('$(NETCoreSdkVersion)', '7.0.0'))"
diff --git a/src/Smdn.Net.MuninNode/Smdn.Net.MuninNode/LocalNode.cs b/src/Smdn.Net.MuninNode/Smdn.Net.MuninNode/LocalNode.cs
index e11dbd0..6844152 100644
--- a/src/Smdn.Net.MuninNode/Smdn.Net.MuninNode/LocalNode.cs
+++ b/src/Smdn.Net.MuninNode/Smdn.Net.MuninNode/LocalNode.cs
@@ -116,5 +116,7 @@ public class LocalNode : NodeBase {
}
protected override bool IsClientAcceptable(IPEndPoint remoteEndPoint)
- => IPAddress.IsLoopback(remoteEndPoint.Address);
+ => IPAddress.IsLoopback(
+ (remoteEndPoint ?? throw new ArgumentNullException(nameof(remoteEndPoint))).Address
+ );
}
diff --git a/src/Smdn.Net.MuninNode/Smdn.Net.MuninNode/NodeBase.cs b/src/Smdn.Net.MuninNode/Smdn.Net.MuninNode/NodeBase.cs
index 08e3ac1..84fe125 100644
--- a/src/Smdn.Net.MuninNode/Smdn.Net.MuninNode/NodeBase.cs
+++ b/src/Smdn.Net.MuninNode/Smdn.Net.MuninNode/NodeBase.cs
@@ -40,7 +40,7 @@ public abstract class NodeBase : IDisposable, IAsyncDisposable {
private readonly ILogger? logger;
private Socket? server;
- public NodeBase(
+ protected NodeBase(
IReadOnlyCollection<IPlugin> plugins,
string hostName,
ILogger? logger
@@ -81,7 +81,7 @@ public abstract class NodeBase : IDisposable, IAsyncDisposable {
try {
if (server is not null && server.Connected) {
#if SYSTEM_NET_SOCKETS_SOCKET_DISCONNECTASYNC_REUSESOCKET_CANCELLATIONTOKEN
- await server.DisconnectAsync(reuseSocket: false);
+ await server.DisconnectAsync(reuseSocket: false).ConfigureAwait(false);
#else
server.Disconnect(reuseSocket: false);
#endif
@@ -159,7 +159,7 @@ public abstract class NodeBase : IDisposable, IAsyncDisposable {
return;
}
- await AcceptSingleSessionAsync(cancellationToken);
+ await AcceptSingleSessionAsync(cancellationToken).ConfigureAwait(false);
}
}
catch (OperationCanceledException ex) {
@@ -243,6 +243,7 @@ public abstract class NodeBase : IDisposable, IAsyncDisposable {
return;
}
+#pragma warning disable CA1031
catch (Exception ex) {
logger?.LogCritical(
ex,
@@ -252,6 +253,7 @@ public abstract class NodeBase : IDisposable, IAsyncDisposable {
return;
}
+#pragma warning restore CA1031
cancellationToken.ThrowIfCancellationRequested();
@@ -267,8 +269,8 @@ public abstract class NodeBase : IDisposable, IAsyncDisposable {
var pipe = new Pipe();
await Task.WhenAll(
- FillAsync(client, remoteEndPoint, pipe.Writer, cancellationToken),
- ReadAsync(client, remoteEndPoint, pipe.Reader, cancellationToken)
+ ReceiveCommandAsync(client, remoteEndPoint, pipe.Writer, cancellationToken),
+ ProcessCommandAsync(client, remoteEndPoint, pipe.Reader, cancellationToken)
).ConfigureAwait(false);
logger?.LogInformation("[{RemoteEndPoint}] session closed; ID={SessionId}", remoteEndPoint, sessionId);
@@ -285,8 +287,9 @@ public abstract class NodeBase : IDisposable, IAsyncDisposable {
logger?.LogInformation("[{RemoteEndPoint}] connection closed", remoteEndPoint);
}
+ }
- static string GenerateSessionId(EndPoint? localEndPoint, IPEndPoint remoteEndPoint)
+ private static string GenerateSessionId(EndPoint? localEndPoint, IPEndPoint remoteEndPoint)
{
#if SYSTEM_SECURITY_CRYPTOGRAPHY_SHA1_HASHSIZEINBYTES
const int SHA1HashSizeInBytes = SHA1.HashSizeInBytes;
@@ -311,7 +314,7 @@ public abstract class NodeBase : IDisposable, IAsyncDisposable {
return Convert.ToBase64String(sha1hash);
}
- async Task FillAsync(
+ private async Task ReceiveCommandAsync(
Socket socket,
IPEndPoint remoteEndPoint,
PipeWriter writer,
@@ -367,6 +370,7 @@ public abstract class NodeBase : IDisposable, IAsyncDisposable {
);
throw;
}
+#pragma warning disable CA1031
catch (Exception ex) {
logger?.LogCritical(
ex,
@@ -375,6 +379,7 @@ public abstract class NodeBase : IDisposable, IAsyncDisposable {
);
break;
}
+#pragma warning restore CA1031
var result = await writer.FlushAsync(
cancellationToken: cancellationToken
@@ -387,7 +392,7 @@ public abstract class NodeBase : IDisposable, IAsyncDisposable {
await writer.CompleteAsync().ConfigureAwait(false);
}
- async Task ReadAsync(
+ private async Task ProcessCommandAsync(
Socket socket,
IPEndPoint remoteEndPoint,
PipeReader reader,
@@ -404,7 +409,7 @@ public abstract class NodeBase : IDisposable, IAsyncDisposable {
try {
while (TryReadLine(ref buffer, out var line)) {
- await ProcessCommandAsync(
+ await RespondToCommandAsync(
client: socket,
commandLine: line,
cancellationToken: cancellationToken
@@ -418,6 +423,7 @@ public abstract class NodeBase : IDisposable, IAsyncDisposable {
);
throw;
}
+#pragma warning disable CA1031
catch (Exception ex) {
logger?.LogCritical(
ex,
@@ -429,13 +435,13 @@ public abstract class NodeBase : IDisposable, IAsyncDisposable {
socket.Close();
break;
}
+#pragma warning restore CA1031
reader.AdvanceTo(buffer.Start, buffer.End);
if (result.IsCompleted)
break;
}
- }
static bool TryReadLine(ref ReadOnlySequence<byte> buffer, out ReadOnlySequence<byte> line)
{
@@ -507,7 +513,7 @@ public abstract class NodeBase : IDisposable, IAsyncDisposable {
private static readonly byte commandQuitShort = (byte)'.';
#if LANG_VERSION_11_OR_GREATER
- private ValueTask ProcessCommandAsync(
+ private ValueTask RespondToCommandAsync(
Socket client,
ReadOnlySequence<byte> commandLine,
CancellationToken cancellationToken
@@ -560,7 +566,7 @@ public abstract class NodeBase : IDisposable, IAsyncDisposable {
private static readonly ReadOnlyMemory<byte> commandCap = Encoding.ASCII.GetBytes("cap");
private static readonly ReadOnlyMemory<byte> commandVersion = Encoding.ASCII.GetBytes("version");
- private ValueTask ProcessCommandAsync(
+ private ValueTask RespondToCommandAsync(
Socket client,
ReadOnlySequence<byte> commandLine,
CancellationToken cancellationToken
diff --git a/src/Smdn.Net.MuninNode/Smdn.Net.MuninPlugin/Plugin.cs b/src/Smdn.Net.MuninNode/Smdn.Net.MuninPlugin/Plugin.cs
index d36bd91..8a599bf 100644
--- a/src/Smdn.Net.MuninNode/Smdn.Net.MuninPlugin/Plugin.cs
+++ b/src/Smdn.Net.MuninNode/Smdn.Net.MuninPlugin/Plugin.cs
@@ -14,10 +14,13 @@ public class Plugin : IPlugin, IPluginDataSource, INodeSessionCallback {
public PluginGraphAttributes GraphAttributes { get; }
public IReadOnlyCollection<IPluginField> Fields { get; }
+#pragma warning disable CA1033
IPluginDataSource IPlugin.DataSource => this;
+
IReadOnlyCollection<IPluginField> IPluginDataSource.Fields => Fields;
INodeSessionCallback? IPlugin.SessionCallback => this;
+#pragma warning restore CA1033
public Plugin(
string name,
diff --git a/src/Smdn.Net.MuninNode/Smdn.Net.MuninPlugin/PluginFieldBase.cs b/src/Smdn.Net.MuninNode/Smdn.Net.MuninPlugin/PluginFieldBase.cs
index 24c5197..808d264 100644
--- a/src/Smdn.Net.MuninNode/Smdn.Net.MuninPlugin/PluginFieldBase.cs
+++ b/src/Smdn.Net.MuninNode/Smdn.Net.MuninPlugin/PluginFieldBase.cs
@@ -15,12 +15,14 @@ public abstract class PluginFieldBase : IPluginField {
public PluginFieldNormalValueRange NormalRangeForWarning { get; }
public PluginFieldNormalValueRange NormalRangeForCritical { get; }
+#pragma warning disable CA1033
PluginFieldAttributes IPluginField.Attributes => new(
label: Label,
graphStyle: GraphStyle,
normalRangeForWarning: NormalRangeForWarning,
normalRangeForCritical: NormalRangeForCritical
);
+#pragma warning restore CA1033
protected PluginFieldBase(
string label,
@@ -55,6 +57,7 @@ public abstract class PluginFieldBase : IPluginField {
/// <remarks>Reports 'UNKNOWN' as a plugin field value if the return value is <see langword="null"/>.</remarks>
protected abstract ValueTask<double?> FetchValueAsync(CancellationToken cancellationToken);
+#pragma warning disable CA1033
async ValueTask<string> IPluginField.GetFormattedValueStringAsync(CancellationToken cancellationToken)
{
const string unknownValueString = "U";
@@ -63,6 +66,7 @@ public abstract class PluginFieldBase : IPluginField {
return value?.ToString(provider: null) ?? unknownValueString; // TODO: format specifier
}
+#pragma warning restore CA1033
// http://guide.munin-monitoring.org/en/latest/reference/plugin.html#field-name-attributes
// Field name attributes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment