Skip to content

Commit caee3a7

Browse files
committed
Reformat
1 parent 462a995 commit caee3a7

12 files changed

+126
-104
lines changed

src/Proto.Remote/Activator.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
using System;
1+
// -----------------------------------------------------------------------
2+
// <copyright file="Activator.cs" company="Asynkron HB">
3+
// Copyright (C) 2015-2017 Asynkron HB All rights reserved
4+
// </copyright>
5+
// -----------------------------------------------------------------------
6+
27
using System.Threading.Tasks;
38

49
namespace Proto.Remote
@@ -19,7 +24,7 @@ public Task ReceiveAsync(IContext context)
1924
var pid = Actor.SpawnNamed(props, name);
2025
var response = new ActorPidResponse
2126
{
22-
Pid = pid,
27+
Pid = pid
2328
};
2429
context.Respond(response);
2530

src/Proto.Remote/EndpointManager.cs

+36-37
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// -----------------------------------------------------------------------
2-
// <copyright file="EndpointManager.cs" company="Asynkron HB">
3-
// Copyright (C) 2015-2017 Asynkron HB All rights reserved
4-
// </copyright>
2+
// <copyright file="EndpointManager.cs" company="Asynkron HB">
3+
// Copyright (C) 2015-2017 Asynkron HB All rights reserved
4+
// </copyright>
55
// -----------------------------------------------------------------------
66

77
using System;
@@ -40,45 +40,49 @@ public Task ReceiveAsync(IContext context)
4040
switch (context.Message)
4141
{
4242
case Started _:
43-
{
44-
_logger.LogDebug("Started EndpointManager");
45-
return Actor.Done;
46-
}
43+
{
44+
_logger.LogDebug("Started EndpointManager");
45+
return Actor.Done;
46+
}
4747
case EndpointTerminatedEvent msg:
48-
{
49-
var endpoint = EnsureConnected(msg.Address, context);
50-
endpoint.Watcher.Tell(msg);
51-
return Actor.Done;
52-
}
48+
{
49+
var endpoint = EnsureConnected(msg.Address, context);
50+
endpoint.Watcher.Tell(msg);
51+
return Actor.Done;
52+
}
5353
case RemoteTerminate msg:
54-
{
55-
var endpoint = EnsureConnected(msg.Watchee.Address, context);
56-
endpoint.Watcher.Tell(msg);
57-
return Actor.Done;
58-
}
54+
{
55+
var endpoint = EnsureConnected(msg.Watchee.Address, context);
56+
endpoint.Watcher.Tell(msg);
57+
return Actor.Done;
58+
}
5959
case RemoteWatch msg:
60-
{
61-
var endpoint = EnsureConnected(msg.Watchee.Address, context);
62-
endpoint.Watcher.Tell(msg);
63-
return Actor.Done;
64-
}
60+
{
61+
var endpoint = EnsureConnected(msg.Watchee.Address, context);
62+
endpoint.Watcher.Tell(msg);
63+
return Actor.Done;
64+
}
6565
case RemoteUnwatch msg:
66-
{
67-
var endpoint = EnsureConnected(msg.Watchee.Address, context);
68-
endpoint.Watcher.Tell(msg);
69-
return Actor.Done;
70-
}
66+
{
67+
var endpoint = EnsureConnected(msg.Watchee.Address, context);
68+
endpoint.Watcher.Tell(msg);
69+
return Actor.Done;
70+
}
7171
case RemoteDeliver msg:
72-
{
73-
var endpoint = EnsureConnected(msg.Target.Address, context);
74-
endpoint.Writer.Tell(msg);
75-
return Actor.Done;
76-
}
72+
{
73+
var endpoint = EnsureConnected(msg.Target.Address, context);
74+
endpoint.Writer.Tell(msg);
75+
return Actor.Done;
76+
}
7777
default:
7878
return Actor.Done;
7979
}
8080
}
8181

82+
public void HandleFailure(ISupervisor supervisor, PID child, RestartStatistics rs, Exception cause)
83+
{
84+
supervisor.RestartChildren(cause, child);
85+
}
8286

8387
private Endpoint EnsureConnected(string address, IContext context)
8488
{
@@ -111,10 +115,5 @@ private PID SpawnWriter(string address, IContext context)
111115
var writer = context.Spawn(writerProps);
112116
return writer;
113117
}
114-
115-
public void HandleFailure(ISupervisor supervisor, PID child, RestartStatistics rs, Exception cause)
116-
{
117-
supervisor.RestartChildren(cause,child);
118-
}
119118
}
120119
}

src/Proto.Remote/EndpointReader.cs

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
// -----------------------------------------------------------------------
2-
// <copyright file="EndpointReader.cs" company="Asynkron HB">
3-
// Copyright (C) 2015-2017 Asynkron HB All rights reserved
4-
// </copyright>
2+
// <copyright file="EndpointReader.cs" company="Asynkron HB">
3+
// Copyright (C) 2015-2017 Asynkron HB All rights reserved
4+
// </copyright>
55
// -----------------------------------------------------------------------
66

7-
using System;
7+
using System.Collections.Generic;
88
using System.Threading.Tasks;
99
using Grpc.Core;
1010
using Grpc.Core.Utils;
11-
using System.Collections.Generic;
12-
using Proto.Mailbox;
1311

1412
namespace Proto.Remote
1513
{

src/Proto.Remote/EndpointWatcher.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// -----------------------------------------------------------------------
2-
// <copyright file="EndpointWatcher.cs" company="Asynkron HB">
3-
// Copyright (C) 2015-2017 Asynkron HB All rights reserved
4-
// </copyright>
2+
// <copyright file="EndpointWatcher.cs" company="Asynkron HB">
3+
// Copyright (C) 2015-2017 Asynkron HB All rights reserved
4+
// </copyright>
55
// -----------------------------------------------------------------------
66

77
using System.Collections.Generic;
@@ -11,9 +11,9 @@ namespace Proto.Remote
1111
{
1212
public class EndpointWatcher : IActor
1313
{
14+
private readonly Behavior _behavior;
1415
private readonly Dictionary<string, PID> _watched = new Dictionary<string, PID>();
1516
private string _address; //for logging
16-
private readonly Behavior _behavior;
1717

1818
public EndpointWatcher(string address, Behavior behavior)
1919
{

src/Proto.Remote/EndpointWriter.cs

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// -----------------------------------------------------------------------
2-
// <copyright file="EndpointWriter.cs" company="Asynkron HB">
3-
// Copyright (C) 2015-2017 Asynkron HB All rights reserved
4-
// </copyright>
2+
// <copyright file="EndpointWriter.cs" company="Asynkron HB">
3+
// Copyright (C) 2015-2017 Asynkron HB All rights reserved
4+
// </copyright>
55
// -----------------------------------------------------------------------
66

77
using System;
@@ -15,16 +15,15 @@ namespace Proto.Remote
1515
{
1616
public class EndpointWriter : IActor
1717
{
18-
private readonly ILogger _logger = Log.CreateLogger<EndpointWriter>();
19-
2018
private readonly string _address;
19+
private readonly CallOptions _callOptions;
20+
private readonly ChannelCredentials _channelCredentials;
2121
private readonly IEnumerable<ChannelOption> _channelOptions;
22+
private readonly ILogger _logger = Log.CreateLogger<EndpointWriter>();
2223
private Channel _channel;
2324
private Remoting.RemotingClient _client;
2425
private AsyncDuplexStreamingCall<MessageBatch, Unit> _stream;
2526
private IClientStreamWriter<MessageBatch> _streamWriter;
26-
private readonly CallOptions _callOptions;
27-
private readonly ChannelCredentials _channelCredentials;
2827

2928
public EndpointWriter(string address, IEnumerable<ChannelOption> channelOptions, CallOptions callOptions, ChannelCredentials channelCredentials)
3029
{
@@ -76,7 +75,7 @@ public async Task ReceiveAsync(IContext context)
7675
Sender = rd.Sender,
7776
Target = targetId,
7877
TypeId = typeId,
79-
SerializerId = rd.SerializerId,
78+
SerializerId = rd.SerializerId
8079
};
8180
envelopes.Add(envelope);
8281
}

src/Proto.Remote/EndpointWriterMailbox.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
// -----------------------------------------------------------------------
2-
// <copyright file="EndpointWriterMailbox.cs" company="Asynkron HB">
3-
// Copyright (C) 2015-2017 Asynkron HB All rights reserved
4-
// </copyright>
2+
// <copyright file="EndpointWriterMailbox.cs" company="Asynkron HB">
3+
// Copyright (C) 2015-2017 Asynkron HB All rights reserved
4+
// </copyright>
55
// -----------------------------------------------------------------------
66

77
using System;
88
using System.Collections.Generic;
99
using System.Threading;
1010
using System.Threading.Tasks;
11-
using Proto.Mailbox;
1211

1312
namespace Proto.Remote
1413
{

src/Proto.Remote/Messages.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
// -----------------------------------------------------------------------
2-
// <copyright file="Messages.cs" company="Asynkron HB">
3-
// Copyright (C) 2015-2017 Asynkron HB All rights reserved
4-
// </copyright>
2+
// <copyright file="Messages.cs" company="Asynkron HB">
3+
// Copyright (C) 2015-2017 Asynkron HB All rights reserved
4+
// </copyright>
55
// -----------------------------------------------------------------------
6-
76
namespace Proto.Remote
87
{
98
public sealed class EndpointTerminatedEvent

src/Proto.Remote/ProtosGrpc.cs

+32-27
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,92 @@
1-
// Generated by the protocol buffer compiler. DO NOT EDIT!
2-
// source: Protos.proto
1+
// -----------------------------------------------------------------------
2+
// <copyright file="ProtosGrpc.cs" company="Asynkron HB">
3+
// Copyright (C) 2015-2017 Asynkron HB All rights reserved
4+
// </copyright>
5+
// -----------------------------------------------------------------------
36
#region Designer generated code
47

58
using System;
69
using System.Threading;
7-
using System.Threading.Tasks;
810
using Grpc.Core;
911

1012
namespace Proto.Remote {
1113
public static class Remoting
1214
{
13-
static readonly string __ServiceName = "remote.Remoting";
15+
static readonly string __ServiceName = "remote.Remoting";
1416

15-
static readonly Marshaller<global::Proto.Remote.MessageBatch> __Marshaller_MessageBatch = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Proto.Remote.MessageBatch.Parser.ParseFrom);
16-
static readonly Marshaller<global::Proto.Remote.Unit> __Marshaller_Unit = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Proto.Remote.Unit.Parser.ParseFrom);
17+
static readonly Marshaller<global::Proto.Remote.MessageBatch> __Marshaller_MessageBatch = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Proto.Remote.MessageBatch.Parser.ParseFrom);
18+
static readonly Marshaller<global::Proto.Remote.Unit> __Marshaller_Unit = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Proto.Remote.Unit.Parser.ParseFrom);
1719

18-
static readonly Method<global::Proto.Remote.MessageBatch, global::Proto.Remote.Unit> __Method_Receive = new Method<global::Proto.Remote.MessageBatch, global::Proto.Remote.Unit>(
20+
static readonly Method<global::Proto.Remote.MessageBatch, global::Proto.Remote.Unit> __Method_Receive = new Method<global::Proto.Remote.MessageBatch, global::Proto.Remote.Unit>(
1921
MethodType.DuplexStreaming,
2022
__ServiceName,
2123
"Receive",
2224
__Marshaller_MessageBatch,
2325
__Marshaller_Unit);
2426

25-
/// <summary>Service descriptor</summary>
27+
/// <summary>Service descriptor</summary>
2628
public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
2729
{
2830
get { return global::Proto.Remote.ProtosReflection.Descriptor.Services[0]; }
2931
}
3032

31-
/// <summary>Base class for server-side implementations of Remoting</summary>
33+
/// <summary>Creates service definition that can be registered with a server</summary>
34+
public static ServerServiceDefinition BindService(RemotingBase serviceImpl)
35+
{
36+
return ServerServiceDefinition.CreateBuilder()
37+
.AddMethod(__Method_Receive, serviceImpl.Receive).Build();
38+
}
39+
40+
/// <summary>Base class for server-side implementations of Remoting</summary>
3241
public abstract class RemotingBase
3342
{
34-
public virtual global::System.Threading.Tasks.Task Receive(IAsyncStreamReader<global::Proto.Remote.MessageBatch> requestStream, IServerStreamWriter<global::Proto.Remote.Unit> responseStream, ServerCallContext context)
43+
public virtual global::System.Threading.Tasks.Task Receive(IAsyncStreamReader<global::Proto.Remote.MessageBatch> requestStream, IServerStreamWriter<global::Proto.Remote.Unit> responseStream, ServerCallContext context)
3544
{
3645
throw new RpcException(new Status(StatusCode.Unimplemented, ""));
3746
}
38-
3947
}
4048

41-
/// <summary>Client for Remoting</summary>
49+
/// <summary>Client for Remoting</summary>
4250
public class RemotingClient : ClientBase<RemotingClient>
4351
{
44-
/// <summary>Creates a new client for Remoting</summary>
52+
/// <summary>Creates a new client for Remoting</summary>
4553
/// <param name="channel">The channel to use to make remote calls.</param>
4654
public RemotingClient(Channel channel) : base(channel)
4755
{
4856
}
49-
/// <summary>Creates a new client for Remoting that uses a custom <c>CallInvoker</c>.</summary>
57+
58+
/// <summary>Creates a new client for Remoting that uses a custom <c>CallInvoker</c>.</summary>
5059
/// <param name="callInvoker">The callInvoker to use to make remote calls.</param>
5160
public RemotingClient(CallInvoker callInvoker) : base(callInvoker)
5261
{
5362
}
54-
/// <summary>Protected parameterless constructor to allow creation of test doubles.</summary>
63+
64+
/// <summary>Protected parameterless constructor to allow creation of test doubles.</summary>
5565
protected RemotingClient() : base()
5666
{
5767
}
58-
/// <summary>Protected constructor to allow creation of configured clients.</summary>
68+
69+
/// <summary>Protected constructor to allow creation of configured clients.</summary>
5970
/// <param name="configuration">The client configuration.</param>
6071
protected RemotingClient(ClientBaseConfiguration configuration) : base(configuration)
6172
{
6273
}
6374

64-
public virtual AsyncDuplexStreamingCall<global::Proto.Remote.MessageBatch, global::Proto.Remote.Unit> Receive(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
75+
public virtual AsyncDuplexStreamingCall<global::Proto.Remote.MessageBatch, global::Proto.Remote.Unit> Receive(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
6576
{
6677
return Receive(new CallOptions(headers, deadline, cancellationToken));
6778
}
68-
public virtual AsyncDuplexStreamingCall<global::Proto.Remote.MessageBatch, global::Proto.Remote.Unit> Receive(CallOptions options)
79+
80+
public virtual AsyncDuplexStreamingCall<global::Proto.Remote.MessageBatch, global::Proto.Remote.Unit> Receive(CallOptions options)
6981
{
7082
return CallInvoker.AsyncDuplexStreamingCall(__Method_Receive, null, options);
7183
}
72-
protected override RemotingClient NewInstance(ClientBaseConfiguration configuration)
84+
85+
protected override RemotingClient NewInstance(ClientBaseConfiguration configuration)
7386
{
7487
return new RemotingClient(configuration);
7588
}
7689
}
77-
78-
/// <summary>Creates service definition that can be registered with a server</summary>
79-
public static ServerServiceDefinition BindService(RemotingBase serviceImpl)
80-
{
81-
return ServerServiceDefinition.CreateBuilder()
82-
.AddMethod(__Method_Receive, serviceImpl.Receive).Build();
83-
}
84-
8590
}
8691
}
8792
#endregion

0 commit comments

Comments
 (0)