<?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: João Reis</title>
    <description>The latest articles on DEV Community by João Reis (@mrjootta).</description>
    <link>https://dev.to/mrjootta</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F169900%2F3a951e42-8ce9-4d39-aaa3-24540561172e.jpeg</url>
      <title>DEV Community: João Reis</title>
      <link>https://dev.to/mrjootta</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mrjootta"/>
    <language>en</language>
    <item>
      <title>My Go Curated List</title>
      <dc:creator>João Reis</dc:creator>
      <pubDate>Wed, 22 Mar 2023 23:20:00 +0000</pubDate>
      <link>https://dev.to/mrjootta/my-go-curated-list-3obk</link>
      <guid>https://dev.to/mrjootta/my-go-curated-list-3obk</guid>
      <description>&lt;h3&gt;
  
  
  Logging
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/uber-go/zap"&gt;https://github.com/uber-go/zap&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Binaries
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://blog.filippo.io/shrink-your-go-binaries-with-this-one-weird-trick/"&gt;https://blog.filippo.io/shrink-your-go-binaries-with-this-one-weird-trick/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Code decorator
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/hexdigest/gowrap"&gt;https://github.com/hexdigest/gowrap&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Binance Server Location Test</title>
      <dc:creator>João Reis</dc:creator>
      <pubDate>Wed, 22 Mar 2023 23:15:00 +0000</pubDate>
      <link>https://dev.to/mrjootta/binance-server-location-test-5di5</link>
      <guid>https://dev.to/mrjootta/binance-server-location-test-5di5</guid>
      <description>&lt;p&gt;Was doing some tests with Binance API and since the server location it's not public, I tried to rent pin point it's location, here is what I found&lt;/p&gt;

&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Same exact server configuration&lt;/li&gt;
&lt;li&gt;Same bandwith &lt;/li&gt;
&lt;li&gt;Exact same code, used Go to test this out&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  API api.binance.com
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Japan
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;2.08ms&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Singapour
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;1 ms&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Seol
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;1.5 ms&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Frankfurt
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;7.4 ms&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Well hard to tell but I would point out to Singapour, &lt;br&gt;
Binance do not disclose it's servers location,&lt;br&gt;
They do not run replicas in other location as we can see Frankfurt have high ping so no European site&lt;/p&gt;

</description>
      <category>binance</category>
      <category>api</category>
      <category>latency</category>
      <category>go</category>
    </item>
    <item>
      <title>Go global variables in AWS Lambda</title>
      <dc:creator>João Reis</dc:creator>
      <pubDate>Mon, 20 Jan 2020 11:00:34 +0000</pubDate>
      <link>https://dev.to/mrjootta/go-global-variables-in-aws-lambda-148n</link>
      <guid>https://dev.to/mrjootta/go-global-variables-in-aws-lambda-148n</guid>
      <description>&lt;p&gt;As my first story, I decided to write a bit about my recent issue with AWS Lambda and global variables.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--knx1HX-8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1200/1%2AHHWa0RxinMXW3AmP7PRBKQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--knx1HX-8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1200/1%2AHHWa0RxinMXW3AmP7PRBKQ.png" alt="Image credits to https://www.topcoder.com"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Overview
&lt;/h1&gt;

&lt;p&gt;Was happily writing some refactor when for some reason I decided to move the variable that holds the response of the Lambda to a global variable, removing it from the scope of the handler to a global state and changing it inside the handler, at the time I had no clue what I was about to do, now that you have an overview of the situation can you guess what happened?&lt;/p&gt;

&lt;h1&gt;
  
  
  The issue
&lt;/h1&gt;

&lt;p&gt;That lambda response was doing an append due to how we are handling data from DynamoDB, so over multiple calls to that lambda, the response was returning a list of more and more invites even from other accounts.&lt;/p&gt;

&lt;p&gt;This, as you can imagine, was a huge issue, the project was not in production yet so we catch these issues a few days later when the entire team was testing a staging environment with multiple accounts.&lt;/p&gt;

&lt;h1&gt;
  
  
  Resolution
&lt;/h1&gt;

&lt;p&gt;That part was not simple since we just noticed that doing some printf, and that the variable was not clean when the lambda (hot state) was triggered, just simply moving this variable to the Handler fixed the issues.&lt;/p&gt;

&lt;p&gt;Since the lambda do not save the local variables memory state, everything inside the handle will be new at every call.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;It was our first project with lambdas and go so this was not a simple issue to catch, we start to be more careful with what we put as a global variable, there are some external libs initialization that you want to actually make global, so the lambda while hot caches, but never put lambda response or input as variable.&lt;/p&gt;

&lt;p&gt;Create this variables on the handler so they are fresh and clean every time the lambda runs.&lt;/p&gt;

&lt;p&gt;Think twice in what you want to put as global, be careful in this decisions because they can cause a major problem and users get the wrong information or even mixed.&lt;/p&gt;

&lt;p&gt;Always test, integration and manual testing are something that I try to make mandatory on my day to day work, test from multiple contexts always to prevent this to happen.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Ps: If you have any recommendation please send me a message, always open to improve.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>lambda</category>
      <category>go</category>
    </item>
  </channel>
</rss>
