forked from Akkatecture/Akkatecture.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpath---docs-your-first-projections-4f01fade3d2f23611f9f.js
2 lines (2 loc) · 9.12 KB
/
path---docs-your-first-projections-4f01fade3d2f23611f9f.js
1
2
webpackJsonp([36547233318415],{436:function(e,t){e.exports={data:{allPostTitles:{edges:[{node:{frontmatter:{title:"Getting Started",lesson:1,category:"akkatecture",chapter:1,type:"docs"},fields:{slug:"/getting-started"}}},{node:{frontmatter:{title:"Primitives",lesson:1,category:"akkatecture",chapter:2,type:"docs"},fields:{slug:"/primitives"}}},{node:{frontmatter:{title:"Walkthrough Introduction",lesson:1,category:"akkatecture",chapter:3,type:"docs"},fields:{slug:"/walkthrough-introduction"}}},{node:{frontmatter:{title:"Sagas",lesson:1,category:"akkatecture",chapter:4,type:"docs"},fields:{slug:"/sagas"}}},{node:{frontmatter:{title:"Tips and Tricks",lesson:1,category:"akkatecture",chapter:5,type:"docs"},fields:{slug:"/tips-and-tricks"}}},{node:{frontmatter:{title:"Aggregates",lesson:2,category:"akkatecture",chapter:2,type:"docs"},fields:{slug:"/aggregates"}}},{node:{frontmatter:{title:"Your First Aggregate",lesson:2,category:"akkatecture",chapter:3,type:"docs"},fields:{slug:"/your-first-aggregate"}}},{node:{frontmatter:{title:"Snapshotting",lesson:2,category:"akkatecture",chapter:4,type:"docs"},fields:{slug:"/snapshotting"}}},{node:{frontmatter:{title:"Articles",lesson:2,category:"akkatecture",chapter:5,type:"docs"},fields:{slug:"/articles"}}},{node:{frontmatter:{title:"Events",lesson:3,category:"akkatecture",chapter:2,type:"docs"},fields:{slug:"/events"}}},{node:{frontmatter:{title:"Your First Commands",lesson:3,category:"akkatecture",chapter:3,type:"docs"},fields:{slug:"/your-first-commands"}}},{node:{frontmatter:{title:"Clustering",lesson:3,category:"akkatecture",chapter:4,type:"docs"},fields:{slug:"/clustering"}}},{node:{frontmatter:{title:"Videos",lesson:3,category:"akkatecture",chapter:5,type:"docs"},fields:{slug:"/videos"}}},{node:{frontmatter:{title:"Commands",lesson:4,category:"akkatecture",chapter:2,type:"docs"},fields:{slug:"/commands"}}},{node:{frontmatter:{title:"Your First Events",lesson:4,category:"akkatecture",chapter:3,type:"docs"},fields:{slug:"/your-first-events"}}},{node:{frontmatter:{title:"Production Readiness",lesson:4,category:"akkatecture",chapter:4,type:"docs"},fields:{slug:"/production-readiness"}}},{node:{frontmatter:{title:"Specifications",lesson:5,category:"akkatecture",chapter:2,type:"docs"},fields:{slug:"/specifications"}}},{node:{frontmatter:{title:"Your First Specifications",lesson:5,category:"akkatecture",chapter:3,type:"docs"},fields:{slug:"/your-first-specifications"}}},{node:{frontmatter:{title:"Event Upgrading",lesson:5,category:"akkatecture",chapter:4,type:"docs"},fields:{slug:"/event-upgrading"}}},{node:{frontmatter:{title:"Subscribers",lesson:6,category:"akkatecture",chapter:2,type:"docs"},fields:{slug:"/subscribers"}}},{node:{frontmatter:{title:"Your First Aggregate Test",lesson:6,category:"akkatecture",chapter:3,type:"docs"},fields:{slug:"/your-first-aggregate-test"}}},{node:{frontmatter:{title:"Testing Aggregates",lesson:6,category:"akkatecture",chapter:4,type:"docs"},fields:{slug:"/testing-aggregates"}}},{node:{frontmatter:{title:"Scheduled Jobs",lesson:7,category:"akkatecture",chapter:2,type:"docs"},fields:{slug:"/scheduled-jobs"}}},{node:{frontmatter:{title:"Your First Aggregate Saga",lesson:7,category:"akkatecture",chapter:3,type:"docs"},fields:{slug:"/your-first-aggregate-saga"}}},{node:{frontmatter:{title:"Akka",lesson:8,category:"akkatecture",chapter:2,type:"docs"},fields:{slug:"/akka"}}},{node:{frontmatter:{title:"Your First Subscribers",lesson:8,category:"akkatecture",chapter:3,type:"docs"},fields:{slug:"/your-first-subscribers"}}},{node:{frontmatter:{title:"Configuration",lesson:9,category:"akkatecture",chapter:2,type:"docs"},fields:{slug:"/configuration"}}},{node:{frontmatter:{title:"Your First Projections",lesson:9,category:"akkatecture",chapter:3,type:"docs"},fields:{slug:"/your-first-projections"}}},{node:{frontmatter:{title:"Walkthrough Ending",lesson:10,category:"akkatecture",chapter:3,type:"docs"},fields:{slug:"/walkthrough-ending"}}}]},postBySlug:{html:'<p>If you ever need to access the data in your aggregates efficiently, in production, its important that projections (otherwise known as read models) are used from some form of persistent store. Loading aggregates from the event store takes time, and its impossible to do queries for e.g. aggregates that have a specific value in its state. Projections are typically derived partially or mostly by the events stored in the event journal.</p>\n<blockquote>\n<p>Akkatecture has no opinions about how to make projections. since they are just essentially data transfer objects for projections. In the future Akkatecture will ship with a story that deals with durable projections that can be rebuilt or resumed on application start up.</p>\n</blockquote>\n<p>For the purposes of the walkthrough our projection will needs to at least return how much revenue the bank has earned, this can be modelled as followed:</p>\n<div class="gatsby-highlight">\n <pre class="language-csharp"><code class="language-csharp"><span class="token comment">//Walkthrough.Domain/Repositories/Revenue/Projections/RevenueProjection.cs</span>\n<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">RevenueProjection</span>\n<span class="token punctuation">{</span>\n <span class="token keyword">public</span> <span class="token class-name">Money</span> Revenue <span class="token punctuation">{</span> <span class="token keyword">get</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>\n <span class="token keyword">public</span> <span class="token keyword">int</span> Transactions <span class="token punctuation">{</span> <span class="token keyword">get</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>\n\n <span class="token keyword">public</span> <span class="token function">RevenueProjection</span><span class="token punctuation">(</span>\n <span class="token class-name">Money</span> revenue<span class="token punctuation">,</span>\n <span class="token keyword">int</span> transactions<span class="token punctuation">)</span>\n <span class="token punctuation">{</span>\n Revenue <span class="token operator">=</span> revenue<span class="token punctuation">;</span>\n Transactions <span class="token operator">=</span> transactions<span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n<span class="token punctuation">}</span></code></pre>\n </div>\n<p>Our simple query model for retreiving the revenue could be as follows.</p>\n<div class="gatsby-highlight">\n <pre class="language-csharp"><code class="language-csharp"><span class="token comment">//Walkthrough.Domain/Repositories/Revenue/Queries/GetRevenueQuery.cs</span>\n<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">GetRevenueQuery</span>\n<span class="token punctuation">{</span>\n<span class="token punctuation">}</span></code></pre>\n </div>\n<h2 id="a-note-on-projections-and-querymodels"><a href="#a-note-on-projections-and-querymodels" aria-hidden="true" class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>A Note On Projections and QueryModels</h2>\n<p><strong>Resumable Projections</strong> - resumable or durable projections are data models that can self heal themselves. By self-heal we mean that they can regenerate themselves between deployments or when there is some transient failure in the network that leaves the projection a couple of events behind the event publisher (in our case a saga or aggregate root). If a failure is to happen then the projection needs to have some mechanism in place to replay the events that it needs to become consistent with the event publisher. At the time of writing no such capability exists in akkatecture, but it is in development.</p>\n<p><strong>Queries</strong> - Queries are just like commands in a way that they model the intent to get something done, the only difference between a query and a command is that a query is an intent to get information. In your application you can model this around any persistent library. A final note is that projections need not only be for reading data from a persistent store.</p>\n<p><a href="/docs/walkthrough-ending">Next →</a></p>',timeToRead:2,excerpt:"If you ever need to access the data in your aggregates efficiently, in production, its important that projections (otherwise known as read…",frontmatter:{title:"Your First Projections",cover:"https://unsplash.it/400/300/?random?BoldMage",date:"01/07/2018",category:"akkatecture",tags:["walkthrough","akkatecture","projections","csharp","dotnet"]},fields:{slug:"/your-first-projections"}}},pathContext:{slug:"/your-first-projections",category:"akkatecture"}}}});
//# sourceMappingURL=path---docs-your-first-projections-4f01fade3d2f23611f9f.js.map