Share
Embed
Durable Functions 2.0
Andrea Ceroni
October 17, 2019
Transcript
18 slides
-
is the biggest tech conference for developers in EMEA, open
to all languages and technologies. -
NEXT CONFERENCES CODEMOTION MADRID: September, 24-25 CODEMOTION MILAN: October, 24-25
CODEMOTION BERLIN: November, 12-13 CODEMOTION ROME 2020: March, 27-28 CODEMOTION AMSTERDAM 2020: May, 27-28 -
Durable Functions stateful patterns Function chaining F1 F2 F3 Async
HTTP APIs Start DoWork GetStatus Long-running monitor Event aggregator Human interaction RequestApproval ProcessApproval Escalate Fan-out / fan-in F1 F2 F3 -
Durable Functions Actions [DurableClient] IDurableOrchestrationClient Client Function • Start orchestration
• Query orchestration • Terminate orchestration • Signal orchestration • Signal entity • Query entity [OrchestrationTrigger] IDurableOrchestrationContext Orchestrator Function • Call an activity • Call sub-orchestrator • Set status • Call entity [EntityTrigger] IDurableEntityContext Entity Function • Initialize • Destroy • Handle event • Set state • Get state -
Durable Entities Serverless virtual actors very similar to actors (Akka.Net,
Orleans...) but with some substantial differences Explicit state express the state " in an explicit way " and not in the form of a workflow as happens with orchestrators, but they can be used together with orchestrators Reliability for messages (call and signal) "exactly-once" delivery is guaranteed communication takes place through persistent queues (Azure Storage Queue) which guarantee sorting and de-duplication Messages are processed one at a time -
EntityId EntityId an entity is uniquely defined by its id
in the form @EntityType@EntityKey, for example @Light@Hue1 SingnalEntityAsync vs CallEntitiyAsync "signaling" means the enqueue of an operation (asynchronous command, ane-way) "call" instead is usable only inside an orchestrator and returns an answer directly Proxy defining an interface, which the entity will implement, we can perform operations on the entity in a type-safe way avoiding the " magic strings " in code -
Comparison with virtual actors Commons: • addressable via ID •
serial execution of operations • automatically created during the first opeartion • unloaded from memory when not in use • messages are delivered in order and reliably • support for distributed lock via orchestrator • pattern request / response possible only from the orchestrator (entity-to-entity signaling only, as in the actors) Differences: -
public class Question { public string Answer { get; set;
} public void AskAQuestion(string question) => Answer = ThinkAboutTheAnswer( J ); public string GetAnswer() => this.Answer; [FunctionName(nameof(Question))] public static Task Run( [EntityTrigger] IDurableEntityContext ctx, => ctx.DisptachAsync<Question>(); }