/
UdpSettings.cs
96 lines (84 loc) · 3.96 KB
/
UdpSettings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//-----------------------------------------------------------------------
// <copyright file="UdpSettings.cs" company="Akka.NET Project">
// Copyright (C) 2009-2023 Lightbend Inc. <http://www.lightbend.com>
// Copyright (C) 2013-2023 .NET Foundation <https://github.com/akkadotnet/akka.net>
// </copyright>
//-----------------------------------------------------------------------
using System;
using Akka.Actor;
using Akka.Configuration;
namespace Akka.IO
{
public class UdpSettings
{
/// <summary>
/// Creates a new instance of <see cref="UdpSettings"/> class
/// and fills it with values parsed from `akka.io.udp` HOCON
/// path found in actor system.
/// </summary>
public static UdpSettings Create(ActorSystem system)
{
var config = system.Settings.Config.GetConfig("akka.io.udp");
if (config.IsNullOrEmpty())
throw ConfigurationException.NullOrEmptyConfig<UdpSettings>("akka.io.udp");
return Create(config);
}
/// <summary>
/// Creates a new instance of <see cref="UdpSettings"/> class
/// and fills it with values parsed from provided HOCON config.
/// </summary>
/// <param name="config">TBD</param>
public static UdpSettings Create(Config config)
{
if (config.IsNullOrEmpty())
throw ConfigurationException.NullOrEmptyConfig<UdpSettings>();
return new UdpSettings(
bufferPoolConfigPath: config.GetString("buffer-pool", null),
traceLogging: config.GetBoolean("trace-logging", false),
initialSocketAsyncEventArgs: config.GetInt("nr-of-socket-async-event-args", 32),
batchReceiveLimit: config.GetInt("receive-throughput", 0),
managementDispatcher: config.GetString("management-dispatcher", "akka.actor.default-dispatcher"),
fileIoDispatcher: config.GetString("file-io-dispatcher", "akka.actor.default-dispatcher"));
}
public UdpSettings(string bufferPoolConfigPath, bool traceLogging, int initialSocketAsyncEventArgs, int batchReceiveLimit, string managementDispatcher, string fileIoDispatcher)
{
BufferPoolConfigPath = bufferPoolConfigPath;
TraceLogging = traceLogging;
InitialSocketAsyncEventArgs = initialSocketAsyncEventArgs;
BatchReceiveLimit = batchReceiveLimit;
ManagementDispatcher = managementDispatcher;
FileIODispatcher = fileIoDispatcher;
}
/// <summary>
/// A config path to the section defining which byte buffer pool to use.
/// Buffer pools are used to mitigate GC-pressure made by potentiall allocation
/// and deallocation of byte buffers used for writing/receiving data from sockets.
/// </summary>
public string BufferPoolConfigPath { get; }
/// <summary>
/// Enable fine grained logging of what goes on inside the implementation.
/// Be aware that this may log more than once per message sent to the
/// actors of the tcp implementation.
/// </summary>
public bool TraceLogging { get; }
/// <summary>
/// The initial number of SocketAsyncEventArgs to be preallocated. This value
/// will grow infinitely if needed.
/// </summary>
public int InitialSocketAsyncEventArgs { get; }
/// <summary>
/// TBD
/// </summary>
public int BatchReceiveLimit { get; }
/// <summary>
/// Fully qualified config path which holds the dispatcher configuration
/// for the selector management actors
/// </summary>
public string ManagementDispatcher { get; }
/// <summary>
/// Fully qualified config path which holds the dispatcher configuration
/// on which file IO tasks are scheduled
/// </summary>
public string FileIODispatcher { get; }
}
}