<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Oleksii Kraievyi</title>
    <description>The latest articles on DEV Community by Oleksii Kraievyi (@oleksii_kraievyi).</description>
    <link>https://dev.to/oleksii_kraievyi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F402468%2F7d88405f-f890-4e29-a370-713407d0e0c4.jpeg</url>
      <title>DEV Community: Oleksii Kraievyi</title>
      <link>https://dev.to/oleksii_kraievyi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/oleksii_kraievyi"/>
    <language>en</language>
    <item>
      <title>Today, I decided to use vim in my day to day job</title>
      <dc:creator>Oleksii Kraievyi</dc:creator>
      <pubDate>Mon, 22 Jun 2020 10:17:04 +0000</pubDate>
      <link>https://dev.to/oleksii_kraievyi/today-i-decided-to-use-vim-in-my-day-to-day-job-251a</link>
      <guid>https://dev.to/oleksii_kraievyi/today-i-decided-to-use-vim-in-my-day-to-day-job-251a</guid>
      <description>&lt;p&gt;This weekend, I was really inspired to start doing something new . I've been watching lots of cool videos about shell and different command line utilities so I've blown the dust out of my Windows Terminal and installed zsh and decided to use vim as the code editor.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ohmyzsh/ohmyzsh"&gt;https://github.com/ohmyzsh/ohmyzsh&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With powerlevel10k theme&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/romkatv/powerlevel10k"&gt;https://github.com/romkatv/powerlevel10k&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once installed, edit .zshrc file&lt;/p&gt;

&lt;p&gt;ZSH_THEME="powerlevel10k/powerlevel10k"&lt;/p&gt;

&lt;p&gt;And for vim I used vimtutor for learning and ideavim plugin for my JetBrains Rider (i can't really refuse to use code completion and cool refactorings, sorry for that)) )&lt;/p&gt;

&lt;p&gt;Next week, I will write a small review about my experience with vim. Stay tuned&lt;/p&gt;

</description>
      <category>vim</category>
      <category>rider</category>
      <category>ideavim</category>
    </item>
    <item>
      <title>Events immutability problem</title>
      <dc:creator>Oleksii Kraievyi</dc:creator>
      <pubDate>Mon, 15 Jun 2020 13:34:14 +0000</pubDate>
      <link>https://dev.to/oleksii_kraievyi/events-immutability-problem-5c64</link>
      <guid>https://dev.to/oleksii_kraievyi/events-immutability-problem-5c64</guid>
      <description>&lt;p&gt;Hope, you all know the event sourcing. And one of its core principles, that events should be never changed or deleted. But what if you really need it ?&lt;br&gt;
What problem do we have ? For example, you have a &lt;b&gt;User aggregate&lt;/b&gt;. And this aggregate should receive &lt;b&gt;UserCreated&lt;/b&gt; event.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;type&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;UserCreated&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;version&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;123&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;metadata&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;city&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Chicago&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Then this events are applied on read models like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserReadModel&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;IApply&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;UserCreated&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;Id&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IDomainEvent&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;UserCreated&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;@event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Id&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;@event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;@event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And it's working for a year or something. But then manager comes and he says that : "We need to show user city on our UI!". And you don't really know what to do, because your read models are dependent on your events and, in theory, you should support replaying all events from your event store to restore the state of your read models.&lt;/p&gt;

&lt;p&gt;If you can't update and delete your events, you can tell your application, that if the v2 of UserCreated event appears during replaying events it should work with new field, but if the v1 appears, you should emit v2 event with new fields.&lt;/p&gt;

&lt;p&gt;And this thing is called &lt;b&gt;event upgrader&lt;/b&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserCreatedV1ToV2EventUpgrader&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;IDomainEvent&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;UserCreated&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;Upgrade&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IDomainEvent&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;UserCreatedV1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;v1Event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;DomainEvent&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;UserCreated&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;UserCreated&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Id&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;v1Event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;v1Event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;City&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;v1Event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Metadata&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"City"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now, event sourcing becomes a little less complicated &lt;del&gt;(no)&lt;/del&gt;&lt;/p&gt;

</description>
      <category>eventsourcing</category>
      <category>immutability</category>
    </item>
    <item>
      <title>Dependencies in microservices world</title>
      <dc:creator>Oleksii Kraievyi</dc:creator>
      <pubDate>Thu, 11 Jun 2020 15:48:18 +0000</pubDate>
      <link>https://dev.to/oleksii_kraievyi/dependencies-in-microservices-world-4bod</link>
      <guid>https://dev.to/oleksii_kraievyi/dependencies-in-microservices-world-4bod</guid>
      <description>&lt;p&gt;Today we had a brainstorm meeting about how we can eliminate direct dependencies between services in our application. What inputs do we have &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;15-20 microservices&lt;/li&gt;
&lt;li&gt;some of them have cyclic dependencies (service A calls service B and service B calls service A)&lt;/li&gt;
&lt;li&gt;calls does not create anything, just getting some external data&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;After some brief discussions we've came up with some solutions&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We have case when we need to go to external service on each call via middleware and check if user can have an access to app and we can't really eliminate this one. We have a cache on external service , but we've also decided to introduce local cache to even have no network calls&lt;/li&gt;
&lt;li&gt;We have cases when the validation on one service is dependent on state in another service. In this case, we decided to store local copy of this state in scope of single service. We have all needed infrastructure for integration events so it's just the matter of time. (There's also one good point, I've pulled from this meeting - "&lt;b&gt;if you need to call an external service for querying, there's possibility of a bad solution. and for commands - it's completely fine to call 3-rd party services&lt;/b&gt;")&lt;/li&gt;
&lt;li&gt;And the last one is just removing depedency)) What can be easier that that ? We've check a couple of our scenarios and decided that for some cases we don't even need to call external service at all since it won't affect data integrity. For example, we've queried external service to check if resource is found when we were searching data on grid. Isn't this awesome ?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So, notes are written, time to create some tech stories in jira&lt;/p&gt;

</description>
      <category>microservices</category>
    </item>
  </channel>
</rss>
