-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API: Reduce boilerplate when building stream graph #44
Comments
We no longer use Azure Functions in 0.7, hence the approach in the OP won't work. However, in 0.8 there is still boilerplate remaining, as the caller is currently responsible for configuring the stream to match the callee's output. Example (from perper/samples/dotnet/BasicSample/Calls/Init.cs Lines 16 to 17 in d367dde
Ideally we would want the caller ( My proposal would be to make streams (e.g. API Proposals// Usage site:
var generator = PerperContext.CallAsync<PerperStream>("Generator", 10);
var processor = PerperContext.CallAsync<PerperStream>("Processor", generator);
// 1. Definition site w/ Attributes:
class Generator {
[PeperPersistentStream] [PeperReplayStream] [PerperIndexStream(typeof(X))]
public IAsyncEnumerable<(long, X)> RunAsync(int x) { ... }
}
class GeneratorAgent {
[PeperPersistentStream] [PeperReplayStream] [PerperIndexStream(typeof(X))]
public IAsyncEnumerable<(long, X)> GeneratorAsync(int x) { ... }
}
// 2. Definition site w/ Additional method or property:
class Generator {
public PerperStreamOptions StreamOptions => new StreamOptions().Persistent().Index(typeof(X)).Replay();
public IAsyncEnumerable<(long, X)> RunAsync(int x) { ... }
}
class GeneratorAgent {
public PerperStreamOptions GeneratorStreamOptions => new StreamOptions().Persistent().Index(typeof(X)).Replay();
public IAsyncEnumerable<(long, X)> GeneratorAsync(int x) { ... }
}
// 3. Definition site w/ Additional utility method:
class Generator {
public async Task<PerperStream> RunAsync(int x) =>
(await new StreamBuilder().Persistent().Index(typeof(X)).MakeStream(StreamAsync(x))).Replay();
private IAsyncEnumerable<(long, X)> StreamAsync(int x) { ... }
}
class GeneratorAgent {
public async Task<PerperStream> GeneratorAsync(int x) =>
(await new StreamBuilder().Persistent().Index(typeof(X)).MakeStream(StreamAsync(x))).Replay();
private IAsyncEnumerable<(long, X)> StreamAsync(int x) { ... }
} Additional considerations:
Retagging to 0.8, though it is possible it might have to wait for 0.9 if there is no suitable API proposal. |
Azure Functions Extensions collects all of the metadata of the functions (function.json / attributes) that can be passed to stream context to reduce boilerplate when building stream graph.
The text was updated successfully, but these errors were encountered: