-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separated messaging layer from UserChannel (#689)
Separated messaging layer from UserChannel.
- Loading branch information
Showing
35 changed files
with
369 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Morgan Stanley makes this available to you under the Apache License, | ||
// Version 2.0 (the "License"). You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// See the NOTICE file distributed with this work for additional information | ||
// regarding copyright ownership. Unless required by applicable law or agreed | ||
// to in writing, software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
// or implied. See the License for the specific language governing permissions | ||
// and limitations under the License. | ||
|
||
namespace MorganStanley.ComposeUI.Messaging.Abstractions | ||
{ | ||
public interface IMessageBuffer | ||
{ | ||
/// <summary> | ||
/// Gets the bytes of the underlying buffer as a <see cref="ReadOnlySpan{T}" /> | ||
/// </summary> | ||
/// <returns></returns> | ||
ReadOnlySpan<byte> GetSpan(); | ||
|
||
/// <summary> | ||
/// Gets the string value of the buffer. | ||
/// </summary> | ||
/// <returns></returns> | ||
string GetString(); | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
src/messaging/dotnet/src/Abstractions/IMessagingService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// Morgan Stanley makes this available to you under the Apache License, | ||
// Version 2.0 (the "License"). You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// See the NOTICE file distributed with this work for additional information | ||
// regarding copyright ownership. Unless required by applicable law or agreed | ||
// to in writing, software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
// or implied. See the License for the specific language governing permissions | ||
// and limitations under the License. | ||
|
||
namespace MorganStanley.ComposeUI.Messaging.Abstractions | ||
{ | ||
public interface IMessagingService : IAsyncDisposable | ||
{ | ||
/// <summary> | ||
/// Gets the client ID of the current connection. | ||
/// </summary> | ||
/// <remarks> | ||
/// The returned value will be <value>null</value> if the client is not connected. | ||
/// </remarks> | ||
string? ClientId { get; } | ||
|
||
/// <summary> | ||
/// Asynchronously connects to the Message Router server endpoint. | ||
/// </summary> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
/// <remarks> | ||
/// Clients don't need to call this method before calling other methods on this type. | ||
/// The client should automatically establish a connection when needed. | ||
/// </remarks> | ||
ValueTask ConnectAsync(CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Gets an observable that represents a topic. | ||
/// </summary> | ||
/// <param name="topic"></param> | ||
/// <param name="subscriber"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
ValueTask<IAsyncDisposable> SubscribeAsync(string topic, | ||
Func<IMessageBuffer, ValueTask> subscriber, | ||
CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Publishes a message to a topic. | ||
/// </summary> | ||
/// <param name="topic"></param> | ||
/// <param name="payload"></param> | ||
/// <param name="options"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
ValueTask PublishAsync(string topic, | ||
IMessageBuffer? message = null, | ||
PublishOptions optinos = default, | ||
CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Registers a service by providing a name and handler. | ||
/// </summary> | ||
/// <param name="endpoint"></param> | ||
/// <param name="subscriber"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
ValueTask RegisterServiceAsync(string endpoint, | ||
Func<string, IMessageBuffer?, MessageContext?, ValueTask<IMessageBuffer?>> subscriber, | ||
CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Removes a service registration. | ||
/// </summary> | ||
/// <param name="endpoint"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
ValueTask UnregisterServiceAsync(string endpoint, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Invokes a named service. | ||
/// </summary> | ||
/// <param name="endpoint"></param> | ||
/// <param name="payload"></param> | ||
/// <param name="options"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
ValueTask<IMessageBuffer?> InvokeAsync( | ||
string endpoint, | ||
IMessageBuffer? payload = null, | ||
InvokeOptions options = default, | ||
CancellationToken cancellationToken = default); | ||
} | ||
} |
Oops, something went wrong.