Skip to content

Alternative synchronous request handler and asynchronous observer handler. #26

@veblush

Description

@veblush

For example, let's say we have following simple IHelloWorld interface.

public interface IHelloWorld : IInterfacedActor {
    Task<string> SayHello(string name);
    Task<int> GetHelloCount();
}

For writing an actor implementing this interface, simple inheritance would be ok.

public class HelloWorld : InterfacedActor, IHelloWorld {
    Task<string> SayHello(string name) { ... }
    Task<int> GetHelloCount() { ... }
}

However when synchronous handlers are enough, async code could be verbose and inefficient. To handle this we can use an extended interface at a price of losing built-in type safety.

public class HelloWorld : InterfacedActor, IExtendedHandler<IHelloWorld> {
    [ExtendedHandler] string SayHello(string name) { ... }
    [ExtendedHandler] int GetHelloCount() { ... }
}

Instead of extended handler, how about using IHelloWorldSync ? It provides an alternative way to implement sync handlers for interface.

public class HelloWorld : InterfacedActor, IHelloWorldSync {
    string SayHello(string name) { ... }
    int GetHelloCount() { ... }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions