This is an automated email from the ASF dual-hosted git repository.
lizhanhui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-csharp.git
The following commit(s) were added to refs/heads/develop by this push:
new 25433a6 Fix a series of naming issues (#13)
25433a6 is described below
commit 25433a619ef8de75daf6c3659b52fd78c2b269cb
Author: aaron ai <[email protected]>
AuthorDate: Mon Feb 28 13:13:33 2022 +0800
Fix a series of naming issues (#13)
---
examples/Program.cs | 2 +-
rocketmq-client-csharp/Address.cs | 2 +-
rocketmq-client-csharp/AddressScheme.cs | 2 +-
rocketmq-client-csharp/Broker.cs | 2 +-
rocketmq-client-csharp/Client.cs | 123 +++++++++++----------
rocketmq-client-csharp/ClientConfig.cs | 34 +++---
rocketmq-client-csharp/ClientLoggerInterceptor.cs | 2 +-
rocketmq-client-csharp/ClientManager.cs | 69 +++++++-----
rocketmq-client-csharp/ClientManagerFactory.cs | 2 +-
.../ConfigFileCredentialsProvider.cs | 2 +-
rocketmq-client-csharp/Credentials.cs | 2 +-
rocketmq-client-csharp/IClient.cs | 8 +-
rocketmq-client-csharp/IClientConfig.cs | 2 +-
rocketmq-client-csharp/IClientManager.cs | 14 +--
rocketmq-client-csharp/ICredentialsProvider.cs | 2 +-
rocketmq-client-csharp/INameServerResolver.cs | 2 +-
rocketmq-client-csharp/IProducer.cs | 5 +-
rocketmq-client-csharp/IRpcClient.cs | 4 +-
rocketmq-client-csharp/Message.cs | 3 +-
rocketmq-client-csharp/MessageIdGenerator.cs | 2 +-
rocketmq-client-csharp/MessageType.cs | 4 +-
rocketmq-client-csharp/MetadataConstants.cs | 2 +-
rocketmq-client-csharp/MqLogManager.cs | 2 +-
rocketmq-client-csharp/Partition.cs | 2 +-
rocketmq-client-csharp/Permission.cs | 14 ++-
rocketmq-client-csharp/Producer.cs | 20 ++--
.../Protos/apache/rocketmq/v1/admin.proto | 1 +
.../Protos/apache/rocketmq/v1/definition.proto | 3 +-
.../Protos/apache/rocketmq/v1/service.proto | 27 +++--
rocketmq-client-csharp/PublishLoadBalancer.cs | 10 +-
rocketmq-client-csharp/RpcClient.cs | 4 +-
rocketmq-client-csharp/SendResult.cs | 3 +-
rocketmq-client-csharp/SendStatus.cs | 2 +-
rocketmq-client-csharp/SequenceGenerator.cs | 2 +-
rocketmq-client-csharp/ServiceAddress.cs | 27 ++---
rocketmq-client-csharp/Signature.cs | 2 +-
.../StaticCredentialsProvider.cs | 2 +-
rocketmq-client-csharp/StaticNameServerResolver.cs | 2 +-
rocketmq-client-csharp/Topic.cs | 8 +-
rocketmq-client-csharp/TopicRouteData.cs | 45 ++++----
rocketmq-client-csharp/TopicRouteException.cs | 2 +-
rocketmq-client-csharp/Utilities.cs | 2 +-
.../rocketmq-client-csharp.csproj | 2 +-
tests/BrokerTest.cs | 2 +-
tests/ClientConfigTest.cs | 2 +-
tests/ClientManagerTest.cs | 14 +--
tests/ConfigFileCredentialsProviderTest.cs | 2 +-
tests/DateTimeTest.cs | 2 +-
tests/MessageIdGeneratorTest.cs | 2 +-
tests/MessageTest.cs | 2 +-
tests/MqLogManagerTest.cs | 2 +-
tests/ProducerTest.cs | 2 +-
tests/RpcClientTest.cs | 5 +-
tests/SendResultTest.cs | 2 +-
tests/SequenceGeneratorTest.cs | 2 +-
tests/SignatureTest.cs | 2 +-
tests/StaticCredentialsProviderTest.cs | 2 +-
tests/StaticNameServerResolverTest.cs | 2 +-
tests/TopicTest.cs | 2 +-
tests/UnitTest1.cs | 15 +--
60 files changed, 270 insertions(+), 264 deletions(-)
diff --git a/examples/Program.cs b/examples/Program.cs
index 9bf745c..d96f41e 100644
--- a/examples/Program.cs
+++ b/examples/Program.cs
@@ -31,7 +31,7 @@ namespace examples
string accessKey = "key";
string accessSecret = "secret";
- var credentials = new
org.apache.rocketmq.StaticCredentialsProvider(accessKey,
accessSecret).getCredentials();
+ var credentials = new
Org.Apache.Rocketmq.StaticCredentialsProvider(accessKey,
accessSecret).getCredentials();
bool expired = credentials.expired();
int workerThreads;
diff --git a/rocketmq-client-csharp/Address.cs
b/rocketmq-client-csharp/Address.cs
index dadf346..a51a0ba 100644
--- a/rocketmq-client-csharp/Address.cs
+++ b/rocketmq-client-csharp/Address.cs
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
public class Address {
public Address(string host, int port) {
this.host = host;
diff --git a/rocketmq-client-csharp/AddressScheme.cs
b/rocketmq-client-csharp/AddressScheme.cs
index 3e95b09..e3cb4c3 100644
--- a/rocketmq-client-csharp/AddressScheme.cs
+++ b/rocketmq-client-csharp/AddressScheme.cs
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
public enum AddressScheme {
IPv4,
IPv6,
diff --git a/rocketmq-client-csharp/Broker.cs b/rocketmq-client-csharp/Broker.cs
index 2f5f675..a3b448d 100644
--- a/rocketmq-client-csharp/Broker.cs
+++ b/rocketmq-client-csharp/Broker.cs
@@ -17,7 +17,7 @@
using System;
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
public class Broker : IComparable<Broker>, IEquatable<Broker> {
public Broker(string name, int id, ServiceAddress address) {
diff --git a/rocketmq-client-csharp/Client.cs b/rocketmq-client-csharp/Client.cs
index 1157bfe..e628d65 100644
--- a/rocketmq-client-csharp/Client.cs
+++ b/rocketmq-client-csharp/Client.cs
@@ -20,12 +20,12 @@ using System.Collections.Concurrent;
using System.Threading.Tasks;
using System.Threading;
using System;
-using rmq = apache.rocketmq.v1;
+using Apache.Rocketmq.V1;
using grpc = global::Grpc.Core;
using NLog;
-namespace org.apache.rocketmq
+namespace Org.Apache.Rocketmq
{
public abstract class Client : ClientConfig, IClient
{
@@ -33,41 +33,41 @@ namespace org.apache.rocketmq
public Client(INameServerResolver resolver, string resourceNamespace)
{
- this.nameServerResolver = resolver;
- this.resourceNamespace_ = resourceNamespace;
- this.clientManager =
ClientManagerFactory.getClientManager(resourceNamespace);
- this.nameServerResolverCTS = new CancellationTokenSource();
+ _nameServerResolver = resolver;
+ _resourceNamespace = resourceNamespace;
+ Manager = ClientManagerFactory.getClientManager(resourceNamespace);
+ _nameServerResolverCts = new CancellationTokenSource();
- this.topicRouteTable = new ConcurrentDictionary<string,
TopicRouteData>();
- this.updateTopicRouteCTS = new CancellationTokenSource();
+ _topicRouteTable = new ConcurrentDictionary<string,
TopicRouteData>();
+ _updateTopicRouteCts = new CancellationTokenSource();
}
public virtual void Start()
{
schedule(async () =>
{
- await updateNameServerList();
- }, 30, nameServerResolverCTS.Token);
+ await UpdateNameServerList();
+ }, 30, _nameServerResolverCts.Token);
schedule(async () =>
{
- await updateTopicRoute();
+ await UpdateTopicRoute();
- }, 30, updateTopicRouteCTS.Token);
+ }, 30, _updateTopicRouteCts.Token);
}
public virtual async Task Shutdown()
{
- Logger.Info($"Shutdown
client[resource-namespace={resourceNamespace_}");
- updateTopicRouteCTS.Cancel();
- nameServerResolverCTS.Cancel();
- await clientManager.Shutdown();
+ Logger.Info($"Shutdown
client[resource-namespace={_resourceNamespace}");
+ _updateTopicRouteCts.Cancel();
+ _nameServerResolverCts.Cancel();
+ await Manager.Shutdown();
}
- private async Task updateNameServerList()
+ private async Task UpdateNameServerList()
{
- List<string> nameServers = await nameServerResolver.resolveAsync();
+ List<string> nameServers = await
_nameServerResolver.resolveAsync();
if (0 == nameServers.Count)
{
// Whoops, something should be wrong. We got an empty name
server list.
@@ -75,7 +75,7 @@ namespace org.apache.rocketmq
return;
}
- if (nameServers.Equals(this.nameServers))
+ if (nameServers.Equals(this._nameServers))
{
Logger.Debug("Name server list remains unchanged");
return;
@@ -83,18 +83,18 @@ namespace org.apache.rocketmq
// Name server list is updated.
// TODO: Locking is required
- this.nameServers = nameServers;
- this.currentNameServerIndex = 0;
+ this._nameServers = nameServers;
+ this._currentNameServerIndex = 0;
}
- private async Task updateTopicRoute()
+ private async Task UpdateTopicRoute()
{
- if (null == nameServers || 0 == nameServers.Count)
+ if (null == _nameServers || 0 == _nameServers.Count)
{
- List<string> list = await nameServerResolver.resolveAsync();
+ List<string> list = await _nameServerResolver.resolveAsync();
if (null != list && 0 != list.Count)
{
- this.nameServers = list;
+ this._nameServers = list;
}
else
{
@@ -104,12 +104,12 @@ namespace org.apache.rocketmq
}
// We got one or more name servers available.
- string nameServer = nameServers[currentNameServerIndex];
+ string nameServer = _nameServers[_currentNameServerIndex];
List<Task<TopicRouteData>> tasks = new
List<Task<TopicRouteData>>();
- foreach (var item in topicRouteTable)
+ foreach (var item in _topicRouteTable)
{
- tasks.Add(getRouteFor(item.Key, true));
+ tasks.Add(GetRouteFor(item.Key, true));
}
// Update topic route data
@@ -127,10 +127,10 @@ namespace org.apache.rocketmq
}
var topicName = item.Partitions[0].Topic.Name;
- var existing = topicRouteTable[topicName];
+ var existing = _topicRouteTable[topicName];
if (!existing.Equals(item))
{
- topicRouteTable[topicName] = item;
+ _topicRouteTable[topicName] = item;
}
}
}
@@ -160,19 +160,19 @@ namespace org.apache.rocketmq
* direct
* Indicate if we should by-pass cache and fetch route entries from
name server.
*/
- public async Task<TopicRouteData> getRouteFor(string topic, bool
direct)
+ public async Task<TopicRouteData> GetRouteFor(string topic, bool
direct)
{
- if (!direct && topicRouteTable.ContainsKey(topic))
+ if (!direct && _topicRouteTable.ContainsKey(topic))
{
- return topicRouteTable[topic];
+ return _topicRouteTable[topic];
}
- if (null == nameServers || 0 == nameServers.Count)
+ if (null == _nameServers || 0 == _nameServers.Count)
{
- List<string> list = await nameServerResolver.resolveAsync();
+ List<string> list = await _nameServerResolver.resolveAsync();
if (null != list && 0 != list.Count)
{
- this.nameServers = list;
+ this._nameServers = list;
}
else
{
@@ -185,15 +185,15 @@ namespace org.apache.rocketmq
for (int retry = 0; retry < MaxTransparentRetry; retry++)
{
// We got one or more name servers available.
- int index = (currentNameServerIndex + retry) %
nameServers.Count;
- string nameServer = nameServers[index];
- var request = new rmq::QueryRouteRequest();
- request.Topic = new rmq::Resource();
- request.Topic.ResourceNamespace = resourceNamespace_;
+ int index = (_currentNameServerIndex + retry) %
_nameServers.Count;
+ string nameServer = _nameServers[index];
+ var request = new QueryRouteRequest();
+ request.Topic = new Resource();
+ request.Topic.ResourceNamespace = _resourceNamespace;
request.Topic.Name = topic;
- request.Endpoints = new rmq::Endpoints();
- request.Endpoints.Scheme = rmq::AddressScheme.Ipv4;
- var address = new rmq::Address();
+ request.Endpoints = new Endpoints();
+ request.Endpoints.Scheme =
global::Apache.Rocketmq.V1.AddressScheme.Ipv4;
+ var address = new global::Apache.Rocketmq.V1.Address();
int pos = nameServer.LastIndexOf(':');
address.Host = nameServer.Substring(0, pos);
address.Port = Int32.Parse(nameServer.Substring(pos + 1));
@@ -201,12 +201,12 @@ namespace org.apache.rocketmq
var target = string.Format("https://{0}:{1}", address.Host,
address.Port);
var metadata = new grpc.Metadata();
Signature.sign(this, metadata);
- var topicRouteData = await clientManager.resolveRoute(target,
metadata, request, getIoTimeout());
+ var topicRouteData = await Manager.ResolveRoute(target,
metadata, request, getIoTimeout());
if (null != topicRouteData)
{
if (retry > 0)
{
- currentNameServerIndex = index;
+ _currentNameServerIndex = index;
}
return topicRouteData;
}
@@ -214,9 +214,9 @@ namespace org.apache.rocketmq
return null;
}
- public abstract void prepareHeartbeatData(rmq::HeartbeatRequest
request);
+ public abstract void PrepareHeartbeatData(HeartbeatRequest request);
- public void heartbeat()
+ public void Heartbeat()
{
List<string> endpoints = endpointsInUse();
if (0 == endpoints.Count)
@@ -224,22 +224,22 @@ namespace org.apache.rocketmq
return;
}
- var heartbeatRequest = new rmq::HeartbeatRequest();
- prepareHeartbeatData(heartbeatRequest);
+ var heartbeatRequest = new HeartbeatRequest();
+ PrepareHeartbeatData(heartbeatRequest);
var metadata = new grpc::Metadata();
Signature.sign(this, metadata);
}
- public void healthCheck()
+ public void HealthCheck()
{
}
- public async Task<bool> notifyClientTermination()
+ public async Task<bool> NotifyClientTermination()
{
List<string> endpoints = endpointsInUse();
- var request = new rmq::NotifyClientTerminationRequest();
+ var request = new NotifyClientTerminationRequest();
request.ClientId = clientId();
var metadata = new grpc.Metadata();
@@ -249,7 +249,7 @@ namespace org.apache.rocketmq
foreach (var endpoint in endpoints)
{
- tasks.Add(clientManager.notifyClientTermination(endpoint,
metadata, request, getIoTimeout()));
+ tasks.Add(Manager.NotifyClientTermination(endpoint, metadata,
request, getIoTimeout()));
}
bool[] results = await Task.WhenAll(tasks);
@@ -269,14 +269,15 @@ namespace org.apache.rocketmq
return new List<string>();
}
- protected IClientManager clientManager;
- private INameServerResolver nameServerResolver;
- private CancellationTokenSource nameServerResolverCTS;
- private List<string> nameServers;
- private int currentNameServerIndex;
+ protected readonly IClientManager Manager;
+
+ private readonly INameServerResolver _nameServerResolver;
+ private readonly CancellationTokenSource _nameServerResolverCts;
+ private List<string> _nameServers;
+ private int _currentNameServerIndex;
- private ConcurrentDictionary<string, TopicRouteData> topicRouteTable;
- private CancellationTokenSource updateTopicRouteCTS;
+ private readonly ConcurrentDictionary<string, TopicRouteData>
_topicRouteTable;
+ private readonly CancellationTokenSource _updateTopicRouteCts;
protected const int MaxTransparentRetry = 3;
}
diff --git a/rocketmq-client-csharp/ClientConfig.cs
b/rocketmq-client-csharp/ClientConfig.cs
index 949f8b4..54052ce 100644
--- a/rocketmq-client-csharp/ClientConfig.cs
+++ b/rocketmq-client-csharp/ClientConfig.cs
@@ -16,7 +16,7 @@
*/
using System;
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
public class ClientConfig : IClientConfig {
@@ -24,29 +24,29 @@ namespace org.apache.rocketmq {
var hostName = System.Net.Dns.GetHostName();
var pid = System.Diagnostics.Process.GetCurrentProcess().Id;
this.clientId_ = string.Format("{0}@{1}#{2}", hostName, pid,
instanceName_);
- this.ioTimeout_ = TimeSpan.FromSeconds(3);
+ this._ioTimeout = TimeSpan.FromSeconds(3);
this.longPollingIoTimeout_ = TimeSpan.FromSeconds(15);
}
public string region() {
- return region_;
+ return _region;
}
public string Region {
- set { region_ = value; }
+ set { _region = value; }
}
public string serviceName() {
- return serviceName_;
+ return _serviceName;
}
public string ServiceName {
- set { serviceName_ = value; }
+ set { _serviceName = value; }
}
public string resourceNamespace() {
- return resourceNamespace_;
+ return _resourceNamespace;
}
public string ResourceNamespace {
- set { resourceNamespace_ = value; }
+ set { _resourceNamespace = value; }
}
public ICredentialsProvider credentialsProvider() {
@@ -58,17 +58,17 @@ namespace org.apache.rocketmq {
}
public string tenantId() {
- return tenantId_;
+ return _tenantId;
}
public string TenantId {
- set { tenantId_ = value; }
+ set { _tenantId = value; }
}
public TimeSpan getIoTimeout() {
- return ioTimeout_;
+ return _ioTimeout;
}
public TimeSpan IoTimeout {
- set { ioTimeout_ = value; }
+ set { _ioTimeout = value; }
}
public TimeSpan getLongPollingTimeout() {
@@ -100,16 +100,16 @@ namespace org.apache.rocketmq {
this.instanceName_ = instanceName;
}
- private string region_ = "cn-hangzhou";
- private string serviceName_ = "ONS";
+ private string _region = "cn-hangzhou";
+ private string _serviceName = "ONS";
- protected string resourceNamespace_;
+ protected string _resourceNamespace;
private ICredentialsProvider credentialsProvider_;
- private string tenantId_;
+ private string _tenantId;
- private TimeSpan ioTimeout_;
+ private TimeSpan _ioTimeout;
private TimeSpan longPollingIoTimeout_;
diff --git a/rocketmq-client-csharp/ClientLoggerInterceptor.cs
b/rocketmq-client-csharp/ClientLoggerInterceptor.cs
index 8bc98ac..01adddc 100644
--- a/rocketmq-client-csharp/ClientLoggerInterceptor.cs
+++ b/rocketmq-client-csharp/ClientLoggerInterceptor.cs
@@ -20,7 +20,7 @@ using Grpc.Core;
using Grpc.Core.Interceptors;
using NLog;
-namespace org.apache.rocketmq
+namespace Org.Apache.Rocketmq
{
public class ClientLoggerInterceptor : Interceptor
{
diff --git a/rocketmq-client-csharp/ClientManager.cs
b/rocketmq-client-csharp/ClientManager.cs
index e79b844..43af961 100644
--- a/rocketmq-client-csharp/ClientManager.cs
+++ b/rocketmq-client-csharp/ClientManager.cs
@@ -15,27 +15,29 @@
* limitations under the License.
*/
-
-using rmq = apache.rocketmq.v1;
+using rmq = Apache.Rocketmq.V1;
using System;
using System.Threading;
using System.Threading.Tasks;
using grpc = Grpc.Core;
using System.Collections.Generic;
-namespace org.apache.rocketmq {
- public class ClientManager : IClientManager {
-
- public ClientManager() {
+namespace Org.Apache.Rocketmq
+{
+ public class ClientManager : IClientManager
+ {
+ public ClientManager()
+ {
_rpcClients = new Dictionary<string, RpcClient>();
_clientLock = new ReaderWriterLockSlim();
}
- public IRpcClient getRpcClient(string target)
+ public IRpcClient GetRpcClient(string target)
{
_clientLock.EnterReadLock();
try
{
+ // client exists, return in advance.
if (_rpcClients.ContainsKey(target))
{
return _rpcClients[target];
@@ -49,11 +51,13 @@ namespace org.apache.rocketmq {
_clientLock.EnterWriteLock();
try
{
+ // client exists, return in advance.
if (_rpcClients.ContainsKey(target))
{
return _rpcClients[target];
}
+ // client does not exist, generate a new one
var client = new RpcClient(target);
_rpcClients.Add(target, client);
return client;
@@ -64,9 +68,10 @@ namespace org.apache.rocketmq {
}
}
- public async Task<TopicRouteData> resolveRoute(string target,
grpc::Metadata metadata, rmq::QueryRouteRequest request, TimeSpan timeout)
+ public async Task<TopicRouteData> ResolveRoute(string target,
grpc::Metadata metadata,
+ rmq::QueryRouteRequest request, TimeSpan timeout)
{
- var rpcClient = getRpcClient(target);
+ var rpcClient = GetRpcClient(target);
var queryRouteResponse = await rpcClient.QueryRoute(metadata,
request, timeout);
if (queryRouteResponse.Common.Status.Code !=
((int)Google.Rpc.Code.Ok))
@@ -80,53 +85,57 @@ namespace org.apache.rocketmq {
{
var topic = new Topic(partition.Topic.ResourceNamespace,
partition.Topic.Name);
var id = partition.Id;
- Permission permission = Permission.READ_WRITE;
- switch (partition.Permission) {
+ Permission permission = Permission.ReadWrite;
+ switch (partition.Permission)
+ {
case rmq::Permission.None:
{
- permission = Permission.NONE;
+ permission = Permission.None;
break;
}
case rmq::Permission.Read:
{
- permission = Permission.READ;
+ permission = Permission.Read;
break;
}
case rmq::Permission.Write:
{
- permission = Permission.WRITE;
+ permission = Permission.Write;
break;
}
case rmq::Permission.ReadWrite:
{
- permission = Permission.READ_WRITE;
+ permission = Permission.ReadWrite;
break;
}
}
AddressScheme scheme = AddressScheme.IPv4;
- switch(partition.Broker.Endpoints.Scheme) {
+ switch (partition.Broker.Endpoints.Scheme)
+ {
case rmq::AddressScheme.Ipv4:
- {
+ {
scheme = AddressScheme.IPv4;
break;
}
case rmq::AddressScheme.Ipv6:
- {
+ {
scheme = AddressScheme.IPv6;
break;
}
case rmq::AddressScheme.DomainName:
- {
+ {
scheme = AddressScheme.DOMAIN_NAME;
break;
}
}
List<Address> addresses = new List<Address>();
- foreach(var item in partition.Broker.Endpoints.Addresses) {
+ foreach (var item in partition.Broker.Endpoints.Addresses)
+ {
addresses.Add(new Address(item.Host, item.Port));
}
+
ServiceAddress serviceAddress = new ServiceAddress(scheme,
addresses);
Broker broker = new Broker(partition.Broker.Name, id,
serviceAddress);
partitions.Add(new Partition(topic, broker, id, permission));
@@ -136,9 +145,10 @@ namespace org.apache.rocketmq {
return topicRouteData;
}
- public async Task<Boolean> heartbeat(string target, grpc::Metadata
metadata, rmq::HeartbeatRequest request, TimeSpan timeout)
+ public async Task<Boolean> Heartbeat(string target, grpc::Metadata
metadata, rmq::HeartbeatRequest request,
+ TimeSpan timeout)
{
- var rpcClient = getRpcClient(target);
+ var rpcClient = GetRpcClient(target);
var response = await rpcClient.Heartbeat(metadata, request,
timeout);
if (null == response)
{
@@ -148,17 +158,20 @@ namespace org.apache.rocketmq {
return response.Common.Status.Code == (int)Google.Rpc.Code.Ok;
}
- public async Task<rmq::SendMessageResponse> sendMessage(string target,
grpc::Metadata metadata, rmq::SendMessageRequest request, TimeSpan timeout)
+ public async Task<rmq::SendMessageResponse> SendMessage(string target,
grpc::Metadata metadata,
+ rmq::SendMessageRequest request, TimeSpan timeout)
{
- var rpcClient = getRpcClient(target);
+ var rpcClient = GetRpcClient(target);
var response = await rpcClient.SendMessage(metadata, request,
timeout);
return response;
}
- public async Task<Boolean> notifyClientTermination(string target,
grpc::Metadata metadata, rmq::NotifyClientTerminationRequest request, TimeSpan
timeout)
+ public async Task<Boolean> NotifyClientTermination(string target,
grpc::Metadata metadata,
+ rmq::NotifyClientTerminationRequest request, TimeSpan timeout)
{
- var rpcClient = getRpcClient(target);
- rmq::NotifyClientTerminationResponse response = await
rpcClient.NotifyClientTermination(metadata, request, timeout);
+ var rpcClient = GetRpcClient(target);
+ rmq::NotifyClientTerminationResponse response =
+ await rpcClient.NotifyClientTermination(metadata, request,
timeout);
return response.Common.Status.Code == ((int)Google.Rpc.Code.Ok);
}
@@ -172,13 +185,13 @@ namespace org.apache.rocketmq {
{
tasks.Add(item.Value.Shutdown());
}
+
await Task.WhenAll(tasks);
}
finally
{
_clientLock.ExitReadLock();
}
-
}
private readonly Dictionary<string, RpcClient> _rpcClients;
diff --git a/rocketmq-client-csharp/ClientManagerFactory.cs
b/rocketmq-client-csharp/ClientManagerFactory.cs
index 3ca211d..9d03994 100644
--- a/rocketmq-client-csharp/ClientManagerFactory.cs
+++ b/rocketmq-client-csharp/ClientManagerFactory.cs
@@ -18,7 +18,7 @@ using System;
using System.Collections.Generic;
using System.Collections.Concurrent;
-namespace org.apache.rocketmq
+namespace Org.Apache.Rocketmq
{
public sealed class ClientManagerFactory
{
diff --git a/rocketmq-client-csharp/ConfigFileCredentialsProvider.cs
b/rocketmq-client-csharp/ConfigFileCredentialsProvider.cs
index 1381b3f..9a3baa3 100644
--- a/rocketmq-client-csharp/ConfigFileCredentialsProvider.cs
+++ b/rocketmq-client-csharp/ConfigFileCredentialsProvider.cs
@@ -19,7 +19,7 @@ using System;
using System.Text.Json;
using System.Collections.Generic;
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
/**
* File-based credentials provider that reads JSON configurations from
${HOME}/.rocketmq/config
diff --git a/rocketmq-client-csharp/Credentials.cs
b/rocketmq-client-csharp/Credentials.cs
index 2da9581..2ccafc8 100644
--- a/rocketmq-client-csharp/Credentials.cs
+++ b/rocketmq-client-csharp/Credentials.cs
@@ -17,7 +17,7 @@
using System;
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
public class Credentials {
public Credentials(string accessKey, string accessSecret) {
diff --git a/rocketmq-client-csharp/IClient.cs
b/rocketmq-client-csharp/IClient.cs
index 7f3ed64..7749c07 100644
--- a/rocketmq-client-csharp/IClient.cs
+++ b/rocketmq-client-csharp/IClient.cs
@@ -17,16 +17,16 @@
using System.Threading.Tasks;
-namespace org.apache.rocketmq
+namespace Org.Apache.Rocketmq
{
public interface IClient : IClientConfig
{
- void heartbeat();
+ void Heartbeat();
- void healthCheck();
+ void HealthCheck();
- Task<bool> notifyClientTermination();
+ Task<bool> NotifyClientTermination();
}
}
\ No newline at end of file
diff --git a/rocketmq-client-csharp/IClientConfig.cs
b/rocketmq-client-csharp/IClientConfig.cs
index b83006c..86c311e 100644
--- a/rocketmq-client-csharp/IClientConfig.cs
+++ b/rocketmq-client-csharp/IClientConfig.cs
@@ -16,7 +16,7 @@
*/
using System;
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
public interface IClientConfig {
string region();
diff --git a/rocketmq-client-csharp/IClientManager.cs
b/rocketmq-client-csharp/IClientManager.cs
index 361638a..3102f60 100644
--- a/rocketmq-client-csharp/IClientManager.cs
+++ b/rocketmq-client-csharp/IClientManager.cs
@@ -15,22 +15,22 @@
* limitations under the License.
*/
-using apache.rocketmq.v1;
+using Apache.Rocketmq.V1;
using System.Threading.Tasks;
using System;
using grpc = global::Grpc.Core;
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
public interface IClientManager {
- IRpcClient getRpcClient(string target);
+ IRpcClient GetRpcClient(string target);
- Task<TopicRouteData> resolveRoute(string target, grpc::Metadata
metadata, QueryRouteRequest request, TimeSpan timeout);
+ Task<TopicRouteData> ResolveRoute(string target, grpc::Metadata
metadata, QueryRouteRequest request, TimeSpan timeout);
- Task<Boolean> heartbeat(string target, grpc::Metadata metadata,
HeartbeatRequest request, TimeSpan timeout);
+ Task<Boolean> Heartbeat(string target, grpc::Metadata metadata,
HeartbeatRequest request, TimeSpan timeout);
- Task<Boolean> notifyClientTermination(string target, grpc::Metadata
metadata, NotifyClientTerminationRequest request, TimeSpan timeout);
+ Task<Boolean> NotifyClientTermination(string target, grpc::Metadata
metadata, NotifyClientTerminationRequest request, TimeSpan timeout);
- Task<SendMessageResponse> sendMessage(string target, grpc::Metadata
metadata, SendMessageRequest request, TimeSpan timeout);
+ Task<SendMessageResponse> SendMessage(string target, grpc::Metadata
metadata, SendMessageRequest request, TimeSpan timeout);
Task Shutdown();
}
diff --git a/rocketmq-client-csharp/ICredentialsProvider.cs
b/rocketmq-client-csharp/ICredentialsProvider.cs
index 6e7112e..80e908f 100644
--- a/rocketmq-client-csharp/ICredentialsProvider.cs
+++ b/rocketmq-client-csharp/ICredentialsProvider.cs
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
public interface ICredentialsProvider {
Credentials getCredentials();
}
diff --git a/rocketmq-client-csharp/INameServerResolver.cs
b/rocketmq-client-csharp/INameServerResolver.cs
index 568098f..4e3d10a 100644
--- a/rocketmq-client-csharp/INameServerResolver.cs
+++ b/rocketmq-client-csharp/INameServerResolver.cs
@@ -18,7 +18,7 @@ using System;
using System.Collections.Generic;
using System.Threading.Tasks;
-namespace org.apache.rocketmq
+namespace Org.Apache.Rocketmq
{
public interface INameServerResolver
{
diff --git a/rocketmq-client-csharp/IProducer.cs
b/rocketmq-client-csharp/IProducer.cs
index 34a3fbd..43a7815 100644
--- a/rocketmq-client-csharp/IProducer.cs
+++ b/rocketmq-client-csharp/IProducer.cs
@@ -14,16 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-using System;
+
using System.Threading.Tasks;
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
public interface IProducer {
void Start();
Task Shutdown();
Task<SendResult> Send(Message message);
-
}
}
\ No newline at end of file
diff --git a/rocketmq-client-csharp/IRpcClient.cs
b/rocketmq-client-csharp/IRpcClient.cs
index 83aaeef..2aaeecf 100644
--- a/rocketmq-client-csharp/IRpcClient.cs
+++ b/rocketmq-client-csharp/IRpcClient.cs
@@ -17,10 +17,10 @@
using System;
using System.Threading.Tasks;
-using apache.rocketmq.v1;
+using Apache.Rocketmq.V1;
using Grpc.Core;
-namespace org.apache.rocketmq
+namespace Org.Apache.Rocketmq
{
public interface IRpcClient
{
diff --git a/rocketmq-client-csharp/Message.cs
b/rocketmq-client-csharp/Message.cs
index 1e6ee0e..66fd47d 100644
--- a/rocketmq-client-csharp/Message.cs
+++ b/rocketmq-client-csharp/Message.cs
@@ -14,8 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System.Collections.Generic;
-namespace org.apache.rocketmq
+namespace Org.Apache.Rocketmq
{
public class Message {
diff --git a/rocketmq-client-csharp/MessageIdGenerator.cs
b/rocketmq-client-csharp/MessageIdGenerator.cs
index 8af1fda..8dc370d 100644
--- a/rocketmq-client-csharp/MessageIdGenerator.cs
+++ b/rocketmq-client-csharp/MessageIdGenerator.cs
@@ -20,7 +20,7 @@ using System.Diagnostics;
using System.IO;
using System.Threading;
-namespace org.apache.rocketmq
+namespace Org.Apache.Rocketmq
{
/**
* MessageId generate rules refer:
https://yuque.antfin-inc.com/aone709911/ca1edg/af2t6o
diff --git a/rocketmq-client-csharp/MessageType.cs
b/rocketmq-client-csharp/MessageType.cs
index 376b658..8373496 100644
--- a/rocketmq-client-csharp/MessageType.cs
+++ b/rocketmq-client-csharp/MessageType.cs
@@ -14,9 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-using System;
-namespace org.apache.rocketmq
+namespace Org.Apache.Rocketmq
{
public enum MessageType {
Normal,
@@ -24,5 +23,4 @@ namespace org.apache.rocketmq
Delay,
Transaction,
}
-
}
\ No newline at end of file
diff --git a/rocketmq-client-csharp/MetadataConstants.cs
b/rocketmq-client-csharp/MetadataConstants.cs
index 184bec8..7e632af 100644
--- a/rocketmq-client-csharp/MetadataConstants.cs
+++ b/rocketmq-client-csharp/MetadataConstants.cs
@@ -17,7 +17,7 @@
using System;
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
public class MetadataConstants {
public const string TENANT_ID_KEY = "x-mq-tenant-id";
public const string NAMESPACE_KEY = "x-mq-namespace";
diff --git a/rocketmq-client-csharp/MqLogManager.cs
b/rocketmq-client-csharp/MqLogManager.cs
index 0608c8a..3d294bd 100644
--- a/rocketmq-client-csharp/MqLogManager.cs
+++ b/rocketmq-client-csharp/MqLogManager.cs
@@ -4,7 +4,7 @@ using System.Reflection;
using NLog;
using NLog.Config;
-namespace org.apache.rocketmq
+namespace Org.Apache.Rocketmq
{
/**
* RocketMQ Log Manager.
diff --git a/rocketmq-client-csharp/Partition.cs
b/rocketmq-client-csharp/Partition.cs
index 410601e..5c9d0bb 100644
--- a/rocketmq-client-csharp/Partition.cs
+++ b/rocketmq-client-csharp/Partition.cs
@@ -16,7 +16,7 @@
*/
using System;
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
public class Partition : IEquatable<Partition>, IComparable<Partition> {
diff --git a/rocketmq-client-csharp/Permission.cs
b/rocketmq-client-csharp/Permission.cs
index 659c15b..6111b20 100644
--- a/rocketmq-client-csharp/Permission.cs
+++ b/rocketmq-client-csharp/Permission.cs
@@ -15,9 +15,13 @@
* limitations under the License.
*/
-public enum Permission {
- NONE,
- READ,
- WRITE,
- READ_WRITE,
+namespace Org.Apache.Rocketmq
+{
+ public enum Permission
+ {
+ None,
+ Read,
+ Write,
+ ReadWrite,
+ }
}
\ No newline at end of file
diff --git a/rocketmq-client-csharp/Producer.cs
b/rocketmq-client-csharp/Producer.cs
index ca64b16..388a4a6 100644
--- a/rocketmq-client-csharp/Producer.cs
+++ b/rocketmq-client-csharp/Producer.cs
@@ -14,17 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System;
using System.Threading.Tasks;
-using rmq = apache.rocketmq.v1;
-using pb = global::Google.Protobuf;
-using grpc = global::Grpc.Core;
+using rmq = Apache.Rocketmq.V1;
using System.Collections.Generic;
using System.Collections.Concurrent;
+using Google.Protobuf;
+using Grpc.Core;
using NLog;
-
-namespace org.apache.rocketmq
+namespace Org.Apache.Rocketmq
{
public class Producer : Client, IProducer
{
@@ -45,7 +45,7 @@ namespace org.apache.rocketmq
await base.Shutdown();
}
- public override void prepareHeartbeatData(rmq::HeartbeatRequest
request)
+ public override void PrepareHeartbeatData(rmq::HeartbeatRequest
request)
{
}
@@ -54,7 +54,7 @@ namespace org.apache.rocketmq
{
if (!loadBalancer.ContainsKey(message.Topic))
{
- var topicRouteData = await getRouteFor(message.Topic, false);
+ var topicRouteData = await GetRouteFor(message.Topic, false);
if (null == topicRouteData || null ==
topicRouteData.Partitions || 0 == topicRouteData.Partitions.Count)
{
Logger.Error($"Failed to resolve route info for
{message.Topic} after {MaxTransparentRetry} attempts");
@@ -69,7 +69,7 @@ namespace org.apache.rocketmq
var request = new rmq::SendMessageRequest();
request.Message = new rmq::Message();
- request.Message.Body = pb::ByteString.CopyFrom(message.Body);
+ request.Message.Body = ByteString.CopyFrom(message.Body);
request.Message.Topic = new rmq::Resource();
request.Message.Topic.ResourceNamespace = resourceNamespace();
request.Message.Topic.Name = message.Topic;
@@ -103,7 +103,7 @@ namespace org.apache.rocketmq
targets.Add(partition.Broker.targetUrl());
}
- var metadata = new grpc::Metadata();
+ var metadata = new Metadata();
Signature.sign(this, metadata);
Exception ex = null;
@@ -112,7 +112,7 @@ namespace org.apache.rocketmq
{
try
{
- rmq::SendMessageResponse response = await
clientManager.sendMessage(target, metadata, request, getIoTimeout());
+ rmq::SendMessageResponse response = await
Manager.SendMessage(target, metadata, request, getIoTimeout());
if (null != response && (int)global::Google.Rpc.Code.Ok ==
response.Common.Status.Code)
{
var messageId = response.MessageId;
diff --git a/rocketmq-client-csharp/Protos/apache/rocketmq/v1/admin.proto
b/rocketmq-client-csharp/Protos/apache/rocketmq/v1/admin.proto
index 554207b..283ca82 100644
--- a/rocketmq-client-csharp/Protos/apache/rocketmq/v1/admin.proto
+++ b/rocketmq-client-csharp/Protos/apache/rocketmq/v1/admin.proto
@@ -18,6 +18,7 @@ syntax = "proto3";
package apache.rocketmq.v1;
option cc_enable_arenas = true;
+option csharp_namespace = "Apache.Rocketmq.V1";
option java_multiple_files = true;
option java_package = "apache.rocketmq.v1";
option java_generate_equals_and_hash = true;
diff --git a/rocketmq-client-csharp/Protos/apache/rocketmq/v1/definition.proto
b/rocketmq-client-csharp/Protos/apache/rocketmq/v1/definition.proto
index 33f4644..efc74bf 100644
--- a/rocketmq-client-csharp/Protos/apache/rocketmq/v1/definition.proto
+++ b/rocketmq-client-csharp/Protos/apache/rocketmq/v1/definition.proto
@@ -20,14 +20,13 @@ import "google/protobuf/duration.proto";
package apache.rocketmq.v1;
+option csharp_namespace = "Apache.Rocketmq.V1";
option java_multiple_files = true;
option java_package = "apache.rocketmq.v1";
option java_generate_equals_and_hash = true;
option java_string_check_utf8 = true;
option java_outer_classname = "MQDomain";
-option csharp_namespace = "apache.rocketmq.v1";
-
enum Permission {
NONE = 0;
READ = 1;
diff --git a/rocketmq-client-csharp/Protos/apache/rocketmq/v1/service.proto
b/rocketmq-client-csharp/Protos/apache/rocketmq/v1/service.proto
index 6f1b4c1..bc0791e 100644
--- a/rocketmq-client-csharp/Protos/apache/rocketmq/v1/service.proto
+++ b/rocketmq-client-csharp/Protos/apache/rocketmq/v1/service.proto
@@ -24,14 +24,13 @@ import "apache/rocketmq/v1/definition.proto";
package apache.rocketmq.v1;
+option csharp_namespace = "Apache.Rocketmq.V1";
option java_multiple_files = true;
option java_package = "apache.rocketmq.v1";
option java_generate_equals_and_hash = true;
option java_string_check_utf8 = true;
option java_outer_classname = "MQService";
-option csharp_namespace = "apache.rocketmq.v1";
-
message ResponseCommon {
google.rpc.Status status = 1;
google.rpc.RequestInfo request_info = 2;
@@ -386,13 +385,13 @@ message NotifyClientTerminationResponse {
// errors raise, return a response with common.status.code == `INTERNAL`.
service MessagingService {
- // Queries the route entries of the requested topic in the perspective of the
+ // Querys the route entries of the requested topic in the perspective of the
// given endpoints. On success, servers should return a collection of
// addressable partitions. Note servers may return customized route entries
// based on endpoints provided.
//
// If the requested topic doesn't exist, returns `NOT_FOUND`.
- // If the specific endpoints is empty, returns `INVALID_ARGUMENT`.
+ // If the specific endpoints is emtpy, returns `INVALID_ARGUMENT`.
rpc QueryRoute(QueryRouteRequest) returns (QueryRouteResponse) {}
// Producer or consumer sends HeartbeatRequest to servers periodically to
@@ -425,17 +424,17 @@ service MessagingService {
// If the destination topic doesn't exist, returns `NOT_FOUND`.
rpc SendMessage(SendMessageRequest) returns (SendMessageResponse) {}
- // Queries the assigned partition route info of a topic for current consumer,
- // the returned assignment result is decided by server-side load balancer.
+ // Querys the assigned partition route info of a topic for current consumer,
+ // the returned assignment result is descided by server-side load balacner.
//
// If the corresponding topic doesn't exist, returns `NOT_FOUND`.
- // If the specific endpoints is empty, returns `INVALID_ARGUMENT`.
+ // If the specific endpoints is emtpy, returns `INVALID_ARGUMENT`.
rpc QueryAssignment(QueryAssignmentRequest)
returns (QueryAssignmentResponse) {}
- // Receives messages from the server in batch manner, returns a batch of
- // messages if success. The received messages should be ACKed or NACKed after
- // processing.
+ // Receives messages from the server in batch manner, returns a set of
+ // messages if success. The received messages should be acked or uacked after
+ // processed.
//
// If the pending concurrent receive requests exceed the quota of the given
// consumer group, returns `UNAVAILABLE`. If the upstream store server hangs,
@@ -470,14 +469,14 @@ service MessagingService {
// Commits or rollback one transactional message.
rpc EndTransaction(EndTransactionRequest) returns (EndTransactionResponse) {}
- // Queries the offset of the specific partition, returns the offset with `OK`
+ // Querys the offset of the specific partition, returns the offset with `OK`
// if success. The message server should maintain a numerical offset for each
- // message in a partition.
+ // message in a parition.
rpc QueryOffset(QueryOffsetRequest) returns (QueryOffsetResponse) {}
// Pulls messages from the specific partition, returns a set of messages with
- // next pull offset. The pulled messages can't be ACKed or NACKed, while the
- // client is responsible for manage offsets for consumer, typically update
+ // next pull offset. The pulled messages can't be acked or nacked, while the
+ // client is responsible for manage offesets for consumer, typically update
// consume offset to local memory or a third-party storage service.
//
// If the pending concurrent receive requests exceed the quota of the given
diff --git a/rocketmq-client-csharp/PublishLoadBalancer.cs
b/rocketmq-client-csharp/PublishLoadBalancer.cs
index 9a1b66d..bf341c1 100644
--- a/rocketmq-client-csharp/PublishLoadBalancer.cs
+++ b/rocketmq-client-csharp/PublishLoadBalancer.cs
@@ -17,7 +17,7 @@
using System;
using System.Collections.Generic;
-namespace org.apache.rocketmq
+namespace Org.Apache.Rocketmq
{
public class PublishLoadBalancer
{
@@ -26,12 +26,12 @@ namespace org.apache.rocketmq
this.partitions = new List<Partition>();
foreach (var partition in route.Partitions)
{
- if (Permission.NONE == partition.Permission)
+ if (Permission.None == partition.Permission)
{
continue;
}
- if (Permission.READ == partition.Permission)
+ if (Permission.Read == partition.Permission)
{
continue;
}
@@ -49,12 +49,12 @@ namespace org.apache.rocketmq
List<Partition> partitions = new List<Partition>();
foreach (var partition in route.Partitions)
{
- if (Permission.NONE == partition.Permission)
+ if (Permission.None == partition.Permission)
{
continue;
}
- if (Permission.READ == partition.Permission)
+ if (Permission.Read == partition.Permission)
{
continue;
}
diff --git a/rocketmq-client-csharp/RpcClient.cs
b/rocketmq-client-csharp/RpcClient.cs
index 05d3dda..27ea7af 100644
--- a/rocketmq-client-csharp/RpcClient.cs
+++ b/rocketmq-client-csharp/RpcClient.cs
@@ -20,12 +20,12 @@ using System.Net.Http;
using System.Net.Security;
using System.Threading;
using System.Threading.Tasks;
-using apache.rocketmq.v1;
+using Apache.Rocketmq.V1;
using Grpc.Core;
using Grpc.Core.Interceptors;
using Grpc.Net.Client;
-namespace org.apache.rocketmq
+namespace Org.Apache.Rocketmq
{
public class RpcClient : IRpcClient
{
diff --git a/rocketmq-client-csharp/SendResult.cs
b/rocketmq-client-csharp/SendResult.cs
index 5967cca..a726ff9 100644
--- a/rocketmq-client-csharp/SendResult.cs
+++ b/rocketmq-client-csharp/SendResult.cs
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-namespace org.apache.rocketmq {
+
+namespace Org.Apache.Rocketmq {
public sealed class SendResult {
public SendResult(string messageId) {
status_ = SendStatus.SEND_OK;
diff --git a/rocketmq-client-csharp/SendStatus.cs
b/rocketmq-client-csharp/SendStatus.cs
index 8964211..b20e1c5 100644
--- a/rocketmq-client-csharp/SendStatus.cs
+++ b/rocketmq-client-csharp/SendStatus.cs
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
public enum SendStatus {
SEND_OK,
FLUSH_DISK_TIMEOUT,
diff --git a/rocketmq-client-csharp/SequenceGenerator.cs
b/rocketmq-client-csharp/SequenceGenerator.cs
index aa92c80..7f4c394 100644
--- a/rocketmq-client-csharp/SequenceGenerator.cs
+++ b/rocketmq-client-csharp/SequenceGenerator.cs
@@ -18,7 +18,7 @@ using System;
using System.Threading;
using System.Net.NetworkInformation;
-namespace org.apache.rocketmq
+namespace Org.Apache.Rocketmq
{
/**
* See https://yuque.antfin-inc.com/aone709911/ca1edg/af2t6o for Sequence
ID spec.
diff --git a/rocketmq-client-csharp/ServiceAddress.cs
b/rocketmq-client-csharp/ServiceAddress.cs
index 4aab213..fadb021 100644
--- a/rocketmq-client-csharp/ServiceAddress.cs
+++ b/rocketmq-client-csharp/ServiceAddress.cs
@@ -15,25 +15,20 @@
* limitations under the License.
*/
+using System;
using System.Collections.Generic;
-namespace org.apache.rocketmq {
- public sealed class ServiceAddress {
-
- public ServiceAddress(AddressScheme scheme, List<Address> addresses) {
- this.scheme = scheme;
- this.addresses = addresses;
- }
-
- private AddressScheme scheme;
- public AddressScheme Scheme {
- get { return scheme; }
- }
-
- private List<Address> addresses;
- public List<Address> Addresses{
- get { return addresses; }
+namespace Org.Apache.Rocketmq
+{
+ public sealed class ServiceAddress
+ {
+ public ServiceAddress(AddressScheme scheme, List<Address> addresses)
+ {
+ Scheme = scheme;
+ Addresses = addresses;
}
+ public AddressScheme Scheme { get; }
+ public List<Address> Addresses { get; }
}
}
\ No newline at end of file
diff --git a/rocketmq-client-csharp/Signature.cs
b/rocketmq-client-csharp/Signature.cs
index 70e038a..d413b15 100644
--- a/rocketmq-client-csharp/Signature.cs
+++ b/rocketmq-client-csharp/Signature.cs
@@ -19,7 +19,7 @@ using System.Text;
using grpc = global::Grpc.Core;
using System.Security.Cryptography;
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
public class Signature {
public static void sign(IClientConfig clientConfig, grpc::Metadata
metadata) {
metadata.Add(MetadataConstants.LANGUAGE_KEY, "DOTNET");
diff --git a/rocketmq-client-csharp/StaticCredentialsProvider.cs
b/rocketmq-client-csharp/StaticCredentialsProvider.cs
index 301613b..d00dba6 100644
--- a/rocketmq-client-csharp/StaticCredentialsProvider.cs
+++ b/rocketmq-client-csharp/StaticCredentialsProvider.cs
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
public class StaticCredentialsProvider : ICredentialsProvider {
public StaticCredentialsProvider(string accessKey, string
accessSecret) {
diff --git a/rocketmq-client-csharp/StaticNameServerResolver.cs
b/rocketmq-client-csharp/StaticNameServerResolver.cs
index 9f97599..0fbf099 100644
--- a/rocketmq-client-csharp/StaticNameServerResolver.cs
+++ b/rocketmq-client-csharp/StaticNameServerResolver.cs
@@ -18,7 +18,7 @@ using System;
using System.Collections.Generic;
using System.Threading.Tasks;
-namespace org.apache.rocketmq
+namespace Org.Apache.Rocketmq
{
public class StaticNameServerResolver : INameServerResolver
{
diff --git a/rocketmq-client-csharp/Topic.cs b/rocketmq-client-csharp/Topic.cs
index dcc7100..5abc5cb 100644
--- a/rocketmq-client-csharp/Topic.cs
+++ b/rocketmq-client-csharp/Topic.cs
@@ -17,14 +17,14 @@
using System;
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
public class Topic : IComparable<Topic>, IEquatable<Topic> {
- public Topic(string resource_namespace, string name) {
- resourceNamespace = resource_namespace;
+ public Topic(string resourceNamespace, string name) {
+ this.resourceNamespace = resourceNamespace;
this.name = name;
}
- private string resourceNamespace;
+ private readonly string resourceNamespace;
public string ResourceNamespace {
get { return resourceNamespace; }
}
diff --git a/rocketmq-client-csharp/TopicRouteData.cs
b/rocketmq-client-csharp/TopicRouteData.cs
index a860669..a751c51 100644
--- a/rocketmq-client-csharp/TopicRouteData.cs
+++ b/rocketmq-client-csharp/TopicRouteData.cs
@@ -14,43 +14,40 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System;
using System.Collections.Generic;
-namespace org.apache.rocketmq {
-
- public class TopicRouteData : IEquatable<TopicRouteData> {
-
- public TopicRouteData(List<Partition> partitions) {
- this.partitions = partitions;
- this.partitions.Sort();
+namespace Org.Apache.Rocketmq
+{
+ public class TopicRouteData : IEquatable<TopicRouteData>
+ {
+ public TopicRouteData(List<Partition> partitions)
+ {
+ Partitions = partitions;
+ Partitions.Sort();
}
- private List<Partition> partitions;
-
- public List<Partition> Partitions {
- get { return partitions; }
- }
+ public List<Partition> Partitions { get; }
- public bool Equals(TopicRouteData other) {
- return partitions.Equals(other.partitions);
+ public bool Equals(TopicRouteData other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return Equals(Partitions, other.Partitions);
}
- public override bool Equals(object other)
+ public override bool Equals(object obj)
{
-
- if (!(other is TopicRouteData)) {
- return false;
- }
-
- return Equals(other as TopicRouteData);
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != this.GetType()) return false;
+ return Equals((TopicRouteData)obj);
}
public override int GetHashCode()
{
- return HashCode.Combine(partitions);
+ return (Partitions != null ? Partitions.GetHashCode() : 0);
}
-
}
-
}
\ No newline at end of file
diff --git a/rocketmq-client-csharp/TopicRouteException.cs
b/rocketmq-client-csharp/TopicRouteException.cs
index b520e72..75462fd 100644
--- a/rocketmq-client-csharp/TopicRouteException.cs
+++ b/rocketmq-client-csharp/TopicRouteException.cs
@@ -15,7 +15,7 @@
* limitations under the License.
*/
using System;
-namespace org.apache.rocketmq
+namespace Org.Apache.Rocketmq
{
public class TopicRouteException : Exception
{
diff --git a/rocketmq-client-csharp/Utilities.cs
b/rocketmq-client-csharp/Utilities.cs
index 1834a77..3d4818f 100644
--- a/rocketmq-client-csharp/Utilities.cs
+++ b/rocketmq-client-csharp/Utilities.cs
@@ -20,7 +20,7 @@ using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
-namespace org.apache.rocketmq
+namespace Org.Apache.Rocketmq
{
public static class Utilities
{
diff --git a/rocketmq-client-csharp/rocketmq-client-csharp.csproj
b/rocketmq-client-csharp/rocketmq-client-csharp.csproj
index 24cc710..7129e9f 100644
--- a/rocketmq-client-csharp/rocketmq-client-csharp.csproj
+++ b/rocketmq-client-csharp/rocketmq-client-csharp.csproj
@@ -6,7 +6,7 @@
<Authors>Zhanhui Li</Authors>
<Company>Apache Software Foundation</Company>
<TargetFramework>net5.0</TargetFramework>
- <RootNamespace>org.apache.rocketmq</RootNamespace>
+ <RootNamespace>Org.Apache.Rocketmq</RootNamespace>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
diff --git a/tests/BrokerTest.cs b/tests/BrokerTest.cs
index 8de89d5..19f6b47 100644
--- a/tests/BrokerTest.cs
+++ b/tests/BrokerTest.cs
@@ -16,7 +16,7 @@
*/
using Microsoft.VisualStudio.TestTools.UnitTesting;
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
[TestClass]
public class BrokerTest {
diff --git a/tests/ClientConfigTest.cs b/tests/ClientConfigTest.cs
index c6d83cf..427d1d2 100644
--- a/tests/ClientConfigTest.cs
+++ b/tests/ClientConfigTest.cs
@@ -17,7 +17,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
[TestClass]
public class ClientConfigTest {
[TestMethod]
diff --git a/tests/ClientManagerTest.cs b/tests/ClientManagerTest.cs
index 0f8bff7..583c599 100644
--- a/tests/ClientManagerTest.cs
+++ b/tests/ClientManagerTest.cs
@@ -15,19 +15,17 @@
* limitations under the License.
*/
using System;
+using Grpc.Core;
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using rmq = apache.rocketmq.v1;
-using grpc = global::Grpc.Core;
-using System.Threading;
-using System.Threading.Tasks;
+using rmq = Apache.Rocketmq.V1;
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
[TestClass]
public class ClientManagerTest {
[TestMethod]
- public void testResolveRoute() {
+ public void TestResolveRoute() {
string topic = "cpp_sdk_standard";
string resourceNamespace = "MQ_INST_1080056302921134_BXuIbML7";
var request = new rmq::QueryRouteRequest();
@@ -41,7 +39,7 @@ namespace org.apache.rocketmq {
address.Port = 80;
request.Endpoints.Addresses.Add(address);
- var metadata = new grpc::Metadata();
+ var metadata = new Metadata();
var clientConfig = new ClientConfig();
var credentialsProvider = new ConfigFileCredentialsProvider();
clientConfig.CredentialsProvider = credentialsProvider;
@@ -50,7 +48,7 @@ namespace org.apache.rocketmq {
Signature.sign(clientConfig, metadata);
var clientManager = new ClientManager();
string target = "https://116.62.231.199:80";
- var topicRouteData = clientManager.resolveRoute(target, metadata,
request, TimeSpan.FromSeconds(3)).GetAwaiter().GetResult();
+ var topicRouteData = clientManager.ResolveRoute(target, metadata,
request, TimeSpan.FromSeconds(3)).GetAwaiter().GetResult();
Console.WriteLine(topicRouteData);
}
}
diff --git a/tests/ConfigFileCredentialsProviderTest.cs
b/tests/ConfigFileCredentialsProviderTest.cs
index f94d364..0d46b98 100644
--- a/tests/ConfigFileCredentialsProviderTest.cs
+++ b/tests/ConfigFileCredentialsProviderTest.cs
@@ -18,7 +18,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
[TestClass]
public class ConfigFileCredentialsProviderTest {
[TestMethod]
diff --git a/tests/DateTimeTest.cs b/tests/DateTimeTest.cs
index 568d59e..0d9a2a7 100644
--- a/tests/DateTimeTest.cs
+++ b/tests/DateTimeTest.cs
@@ -17,7 +17,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
[TestClass]
public class DateTimeTest {
diff --git a/tests/MessageIdGeneratorTest.cs b/tests/MessageIdGeneratorTest.cs
index 6ed34d6..c98e113 100644
--- a/tests/MessageIdGeneratorTest.cs
+++ b/tests/MessageIdGeneratorTest.cs
@@ -16,7 +16,7 @@
*/
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using org.apache.rocketmq;
+using Org.Apache.Rocketmq;
namespace tests
{
diff --git a/tests/MessageTest.cs b/tests/MessageTest.cs
index 3dd7f4b..2de9f54 100644
--- a/tests/MessageTest.cs
+++ b/tests/MessageTest.cs
@@ -19,7 +19,7 @@ using System;
using System.Text;
using System.Collections.Generic;
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
[TestClass]
public class MessageTest {
diff --git a/tests/MqLogManagerTest.cs b/tests/MqLogManagerTest.cs
index 71be3f5..4d163b2 100644
--- a/tests/MqLogManagerTest.cs
+++ b/tests/MqLogManagerTest.cs
@@ -1,7 +1,7 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NLog;
-using org.apache.rocketmq;
+using Org.Apache.Rocketmq;
namespace tests
{
diff --git a/tests/ProducerTest.cs b/tests/ProducerTest.cs
index c05be97..a2ef2c7 100644
--- a/tests/ProducerTest.cs
+++ b/tests/ProducerTest.cs
@@ -18,7 +18,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using System;
-namespace org.apache.rocketmq
+namespace Org.Apache.Rocketmq
{
[TestClass]
diff --git a/tests/RpcClientTest.cs b/tests/RpcClientTest.cs
index f06603f..40e2b64 100644
--- a/tests/RpcClientTest.cs
+++ b/tests/RpcClientTest.cs
@@ -18,13 +18,12 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
using Grpc.Core.Interceptors;
using System.Net.Http;
using Grpc.Net.Client;
-using rmq = global::apache.rocketmq.v1;
+using rmq = global::Apache.Rocketmq.V1;
using grpc = global::Grpc.Core;
using System;
using pb = global::Google.Protobuf;
-
-namespace org.apache.rocketmq
+namespace Org.Apache.Rocketmq
{
[TestClass]
public class RpcClientTest
diff --git a/tests/SendResultTest.cs b/tests/SendResultTest.cs
index 8dd033a..42a013c 100644
--- a/tests/SendResultTest.cs
+++ b/tests/SendResultTest.cs
@@ -17,7 +17,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
[TestClass]
public class SendResultTest {
diff --git a/tests/SequenceGeneratorTest.cs b/tests/SequenceGeneratorTest.cs
index fc0ceb0..9b55334 100644
--- a/tests/SequenceGeneratorTest.cs
+++ b/tests/SequenceGeneratorTest.cs
@@ -19,7 +19,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
-namespace org.apache.rocketmq
+namespace Org.Apache.Rocketmq
{
[TestClass]
public class SequenceGeneratorTest
diff --git a/tests/SignatureTest.cs b/tests/SignatureTest.cs
index cece257..fd6b525 100644
--- a/tests/SignatureTest.cs
+++ b/tests/SignatureTest.cs
@@ -19,7 +19,7 @@ using grpc = global::Grpc.Core;
using Moq;
using System;
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
[TestClass]
public class SignatureTest {
diff --git a/tests/StaticCredentialsProviderTest.cs
b/tests/StaticCredentialsProviderTest.cs
index 20b957e..20b9450 100644
--- a/tests/StaticCredentialsProviderTest.cs
+++ b/tests/StaticCredentialsProviderTest.cs
@@ -17,7 +17,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
[TestClass]
public class StaticCredentialsProviderTest {
diff --git a/tests/StaticNameServerResolverTest.cs
b/tests/StaticNameServerResolverTest.cs
index 88955e9..853be1a 100644
--- a/tests/StaticNameServerResolverTest.cs
+++ b/tests/StaticNameServerResolverTest.cs
@@ -17,7 +17,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
-namespace org.apache.rocketmq
+namespace Org.Apache.Rocketmq
{
[TestClass]
public class StaticNameServerResolverTest
diff --git a/tests/TopicTest.cs b/tests/TopicTest.cs
index fcc15e4..7d9f3f4 100644
--- a/tests/TopicTest.cs
+++ b/tests/TopicTest.cs
@@ -17,7 +17,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
-namespace org.apache.rocketmq {
+namespace Org.Apache.Rocketmq {
[TestClass]
public class TopicTest {
diff --git a/tests/UnitTest1.cs b/tests/UnitTest1.cs
index 6ea8edf..acbad60 100644
--- a/tests/UnitTest1.cs
+++ b/tests/UnitTest1.cs
@@ -1,7 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using org.apache.rocketmq;
+using Org.Apache.Rocketmq;
using Grpc.Net.Client;
-using apache.rocketmq.v1;
+using Apache.Rocketmq.V1;
+
using System;
namespace tests
{
@@ -11,27 +12,27 @@ namespace tests
[TestMethod]
public void TestMethod1()
{
- apache.rocketmq.v1.Permission perm =
apache.rocketmq.v1.Permission.None;
+ Apache.Rocketmq.V1.Permission perm =
Apache.Rocketmq.V1.Permission.None;
switch(perm) {
- case apache.rocketmq.v1.Permission.None:
+ case Apache.Rocketmq.V1.Permission.None:
{
Console.WriteLine("None");
break;
}
- case apache.rocketmq.v1.Permission.Read:
+ case Apache.Rocketmq.V1.Permission.Read:
{
Console.WriteLine("Read");
break;
}
- case apache.rocketmq.v1.Permission.Write:
+ case Apache.Rocketmq.V1.Permission.Write:
{
Console.WriteLine("Write");
break;
}
- case apache.rocketmq.v1.Permission.ReadWrite:
+ case Apache.Rocketmq.V1.Permission.ReadWrite:
{
Console.WriteLine("ReadWrite");
break;