<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jamal On the Code on Medium]]></title>
        <description><![CDATA[Stories by Jamal On the Code on Medium]]></description>
        <link>https://medium.com/@fernandosolivas?source=rss-e34c8a4e6294------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*_7oH_lJTdR9r6K9HsPltaA.jpeg</url>
            <title>Stories by Jamal On the Code on Medium</title>
            <link>https://medium.com/@fernandosolivas?source=rss-e34c8a4e6294------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 01:05:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@fernandosolivas/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Qualidade de Software com: SonarCloud + Bitbucket]]></title>
            <link>https://medium.com/bemobi-tech/qualidade-de-software-com-sonarcloud-bitbucket-5a5e05c2d2d7?source=rss-e34c8a4e6294------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a5e05c2d2d7</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[bitbucket]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[quality-software]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <dc:creator><![CDATA[Jamal On the Code]]></dc:creator>
            <pubDate>Wed, 10 Apr 2019 18:29:36 GMT</pubDate>
            <atom:updated>2019-04-10T18:29:36.360Z</atom:updated>
            <content:encoded><![CDATA[<h3>Integração Contínua com SonarCloud e Bitbucket Cloud.</h3><h4>Como manter seu código sempre em um padrão aceitável de forma automática.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X8xtPqagRPZOH-OydHH4PA.jpeg" /><figcaption>Steven Universe</figcaption></figure><p>Quando falamos de qualidade de software uma das primeiras coisas que nos vêm a mente são os padrões de qualidades definidos. As vezes por um indivíduo ou um time. Aqui na M4U não é diferente, sempre pensamos em qualidade de software, porém quando deixamos para que a qualidade seja garantida de forma manual e voluntária por um membro da equipe, pode ser que em um momento de entregas mais apertadas, a visão crítica do responsável não se torne tão eficaz… Então decidimos adotar o Sonar Cloud para definição de algumas regras básicas de qualidade de software.</p><p><em>Importante! Assumirei que você já tem uma conta no Bitbucket Cloud e no SonarCloud. Vale frisar que ambas são pagas.</em></p><h3>Bitbucket Cloud</h3><p>Um dos maiores <strong>sistemas de controle de versionamento (VCS) </strong>na nuvem é o <a href="http://bitbucket.org/">Bitbucket</a> da <a href="https://www.atlassian.com/">Atlassian</a>, é um versionador de código robusto e com uma vasta opções de &quot;plugins&quot;. Existe duas formas de licença empresarial, são elas: <a href="https://www.atlassian.com/software/bitbucket/pricing?tab=cloud">Bitbucket Cloud</a> e <a href="https://www.atlassian.com/software/bitbucket/enterprise/data-center">Bitbucket Server</a>. Neste post vamos falar somente do <strong>Bitbucket Cloud</strong>, já que essa é a licença que atualmente utilizamos aqui na M4U.</p><p>Como já dito anteriormente, o Bitbucket te da uma grande opções de plugins para complementar e integrar em seu repositório, um deles é uma integração &quot;direta&quot; com o <a href="https://sonarcloud.io/">SonarCloud</a>.</p><h3>SonarCloud</h3><p>O SonarCloud é um serviço em nuvem oferecido pela <a href="https://www.sonarsource.com/">SonarSource</a> e baseado no <a href="https://www.sonarqube.org/">SonarQube</a>. O SonarQube é uma plataforma open source amplamente adotada para inspecionar continuamente a qualidade do código-fonte e detectar bugs, vulnerabilidades e &quot;code smells&quot; em mais de 20 linguagens de programção.</p><p>O SonarCloud lê métricas do código fonte da aplicação enviadas para o serviço para montar um painel para expor as métricas daquele código e através de um mínimo aceitável (Quality Gates) ele te diz onde estão possíveis bugs, &quot;code smells&quot; e outras variáveis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KlGLEpm9BGOgR7ubc45qpQ.png" /><figcaption>Página de métricas do SonarCloud.</figcaption></figure><h3>Vamos Começar!</h3><p>Primeira coisa que devemos fazer é habilitar o plugin do SonarCloud no serviço do Bitbucket. Para isso entre em sua conta do Bitbucket e entre no menu administrativo do seu Bitbucket, como no GIF abaixo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*KkaN2P1MViZQ8_Z71oZsCQ.gif" /></figure><p>Após habilitar, deverá aparecer uma tela do SonarCloud pedindo para que você continue com a configuração de integração entre os serviços.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nLA295oYu1erZxH8zfWQlw.png" /></figure><p>Após realizar esse passo já será possível importar um projeto do Bitbucket para o Sonar. Para isso, clique no botão de<strong> + </strong>e selecione &quot;Analyze new project&quot;. Em seguida iremos selecionar &quot;Setup manually&quot; para gerar um token de autorização para geração das métricas que serão enviadas ao Sonar.</p><p>Preencha os campos abaixo:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SK0F3pJNk0_kbLSumSoBRA.png" /></figure><p>Clicando em &quot;Set Up&quot; um novo diálogo irá abrir dando duas opções: Criar um novo token ou utilizar um que já exista. Fique a seu critério caso queira usar um que já existe. Em seguida, escolha em qual linguagem esse projeto será executado e o Sonar irá mostrar exemplos de como realizar essa integração. Nós iremos utilizar a opção para Go e Linux.</p><pre>sonar-scanner \<br>  -Dsonar.projectKey=sonarlcoud_bitbucket \<br>  -Dsonar.organization=m4u-pospago \<br>  -Dsonar.sources=. \<br>  -Dsonar.host.url=https://sonarcloud.io \<br>  -Dsonar.login=&lt;token_autorizacao&gt;</pre><p>Já tendo o Bitbucket e o Sonar já configurados vamos pela página de seu repositório configurar o projeto no Sonar que foi criado de forma manual. Esse link entre os dois servições é importante para a inclusão de algumas funcionalidades que iremos mostrar posteriormente.</p><p>Na página de configuração do seu repositório, um dos últimos itens na aba da configuração deverá ser o Sonar, como mostra o gif a seguir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*UagRwM4OTf6pWdU8sYGeJQ.gif" /></figure><p>Habilitando a “<strong>Show repository overview widget” </strong>será possível ver as informações do sonar na tela inicial do seu repositório.</p><h3><strong>Enviando Métricas ao Sonar</strong></h3><p>Após ter nossa integração com Sonar x Bitbucket funcionando podemos começar a enviar nossas métricas para o Sonar. Para isso aconselho que utilize o <a href="https://bitbucket.org/fernandosoliva/go-sonarcloud/src/master/"><strong>código base</strong></a> utilizado para esse post, ele contém as métricas que iremos avaliar aqui.</p><p>É necessário ter o Golang instalado para geração do build e o report de testes com percentual de cobertura. Caso você ainda não tenha a instalação é bem fácil, aconselho a seguir o <a href="https://github.com/golang/go/wiki/Ubuntu">tutorial oficial no GitHub</a> para a instalação.</p><p>Após ambiente instalado com a versão mais recente do Go, iremos realizar o download do código fonte. Abra seu terminal e em um diretório de preferência execute o seguinte comando.</p><pre>git clone https:<em>//fernandosoliva@bitbucket.org/fernandosoliva/go-sonarcloud.git</em></pre><p>Isso irá realizar o download do código base para seu computador. Após o download entre na pasta gerada com o nome <strong>go-sonarcloud </strong>e execute o comando a seguir no terminal:</p><pre>go test -json $(go list ./... ) -cover -coverpkg $(go list ./... | tr &#39;\n&#39; &#39;,&#39;) -coverprofile coverage.txt</pre><p>Esse comando irá fazer com que o Go de forma recursiva rode todos os testes em seu diretório (<strong>go test -json</strong> <strong>$(go list ./… )</strong>), complementar com os dados de cobertura de testes em todos os pacotes existente (<strong>-cover -coverpkg $(go list ./… | tr ‘\n’ ‘,’)</strong>) e finalmente gerar um arquivo com os insumos de teste (<strong>-coverprofile coverage.txt</strong>). Com o arquivo coverage.txt gerado, iremos realizar o envio dos dados para o Sonar com o comando que vimos anteriormente, porém com um comando adicional.</p><pre>sonar-scanner \<br>  -Dsonar.projectKey=sonarlcoud_bitbucket \<br>  -Dsonar.organization=m4u-pospago \<br>  -Dsonar.sources=. \<br>  -Dsonar.host.url=https://sonarcloud.io \<br>  -Dsonar.login=&lt;token_autorizacao&gt; \<br>  <strong>-Dsonar.go.coverage.reportPaths=coverage.txt</strong></pre><p>Após a conclusão do <strong>sonar-scanner </strong>você verá os dados do sonar na página inicial do seu repositório, como a imagem abaixo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KithxLLQXUt6pgK1BMkQDQ.png" /></figure><p>Perceba que a propriedade <strong>sonar.projectKey </strong>não precisa ser igual ao nome do seu repositório e a integração funcionará da mesma forma.</p><h3><strong>Integração Contínua</strong></h3><p>Agora com nossa integração Sonar x Bitbucket funcional, teremos que a cada alteração realizar esse passo a passo para enviar as métricas ao Sonar. O Bitbucket nos oferece um plugin chamado <a href="https://bitbucket.org/product/features/pipelines">Pipelines</a>. Nele é possível configurar uma <a href="https://aws.amazon.com/pt/devops/continuous-integration/">integração contínua</a> para enviar essas métricas automaticamente ao Sonar a cada novo código que é inserido no seu repositório.</p><p>O Pipelines já vem (ou deveria) vir habilitado por padrão para seu repositório, no entanto é precisso adicionar um arquivo de configuração para que ele realize os passos que você gostaria, abaixo um arquivo de exemplo para nosso repositório.</p><pre><strong>image</strong>: golang:1.11<br><br><strong>pipelines</strong>:<br>  <strong>default</strong>:<br>    - <strong>step</strong>:<br>        <strong>script</strong>:<br>          - go test -json $(go list ./...) -cover -coverpkg $(go list ./... | tr &#39;\n&#39; &#39;,&#39;) -coverprofile coverage.txt<br>        <strong>artifacts</strong>:<br>          - coverage.txt<br><br>    - <strong>step</strong>:<br>        <strong>name</strong>: Send SonarCloud Metrics<br>        <strong>script</strong>:<br>          - <strong>pipe</strong>: sonarsource/sonarcloud-scan:0.1.5<br>            <strong>variables</strong>:<br>              <strong>SONAR_TOKEN</strong>: ${SONAR_TOKEN} <em># variável configurada no repositório<br>              </em><strong>EXTRA_ARGS</strong>: -Dsonar.projectKey=sonarcloud_bitbucket -Dsonar.organization=m4u-pospago -Dsonar.go.coverage.reportPaths=coverage.txt -Dsonar.go.exclusions=**_test.go</pre><p>Com esse arquivo será possível adicionar ao Bitbucket Pipelines a integração direta com o Sonar após cada commit novo em seu repositório. Veja que ao invés de utilizarmos o valor direto do nosso token de permissão do Sonar, utilizamos através da variáveis de repositório, que é a forma mais segura de se passar senhas, tokens de autenticação ou qualquer tipo de credencial.</p><p>Após a conclusão do seu build, verá novas métricas no painel do SonarCloud, em nosso caso eu incluí novos testes vermos um aumento em nossas métricas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ja6WR6FPrnjOypZrUQuWjg.png" /><figcaption>Sonar Painel</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G-vuotuIq2NXXRBlEBVJPA.png" /><figcaption>Bitbucket Cloud Repository</figcaption></figure><p>Perceba que houve um decréscimo na quantidade de linhas. No primeiro build não ignoramos os arquivos de testes, então o sonar entende que eles precisariam ser testados <strong>também</strong>. Em nosso <strong>bitbucket-pipelines.yml </strong>ignoramos todos os arquivos <strong>**_test.go.</strong></p><h4>Analisando Pull Requests</h4><p>Uma das funcionalidades mais interessantes na integração entre Sonar e Bitbucket é a análise automática de Pull Requests, isso significa que, uma vez que seu <strong>Quality Gate </strong>não é atendido o Sonar gera um build com falha no seu repositório, podendo assim bloquear merge pull requests que estejam incluindo bugs ou não estão atendendo a seu padrão de qualidade. Para configurar essa integração é necessário incluir algumas variáveis em nosso passo de envio de métrica para o Sonar no <strong>bitbucket-pipelines.yml</strong>.</p><pre>#... bitbucket-pipelines.yml substituir variável EXTRA_ARGS pelo conteúdo abaixo</pre><pre><strong>EXTRA_ARGS</strong>: -Dsonar.projectKey=sonarlcoud_bitbucket  -Dsonar.organization=m4u-pospago -Dsonar.go.coverage.reportPaths=coverage.txt -D<strong>sonar.pullrequest.branch</strong>=$BITBUCKET_BRANCH -D<strong>sonar.pullrequest.base</strong>=$BITBUCKET_PR_DESTINATION_BRANCH -D<strong>sonar.pullrequest.key</strong>=$BITBUCKET_PR_ID -D<strong>sonar.pullrequest.provider</strong>=bitbucketcloud -D<strong>sonar.pullrequest.bitbucketcloud.repository</strong>=$BITBUCKET_REPO_UUID -D<strong>sonar.pullrequest.bitbucketcloud.owner</strong>=$BITBUCKET_REPO_OWNER_UUID</pre><p>Essas e mais propriedades podem serem encontradas na própria documentação do Sonar, na seção de “<a href="https://sonarcloud.io/documentation/analysis/pull-request/">Pull Request Analysis</a>”. Após essa inclusão, quando um pull request for criado o Sonar irá fazer a comparação com a branch de destino e caso haja quebra de Quality Gate, você verá na lista de builds algo parecido com a imagem abaixo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*9yztAPjA6KMKC2H3ZYF2Vw.png" /></figure><p>E assim você pode posteriormente configurar para que seu repositório não aceite merges de pull requests com builds quebrados, adicionar mais informações no “Pull Request Analysis” do Sonar, entre outras opções.</p><h3>Conclusão</h3><p>Ambos os serviços fornecem uma variedade grande de integração e de customização. Sonar + Bitbucket facilita muito o trabalho que as vezes é feito durante um Code Review ou durante o processo de build de um repositório. É sempre válido automatizar um processo como este para garantir a qualidade de novas entregas e com esse processo configurado, citando o Sonar Cloud:</p><blockquote><strong>“There is no longer an excuse for pushing issues to the master.”</strong></blockquote><p>Espero que tenham gostado! É muito importante feedback. Tendo dúvidas pode perguntar que tentaremos responder sempre que possível. Grande abraço e até a próxima.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a5e05c2d2d7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bemobi-tech/qualidade-de-software-com-sonarcloud-bitbucket-5a5e05c2d2d7">Qualidade de Software com: SonarCloud + Bitbucket</a> was originally published in <a href="https://medium.com/bemobi-tech">Bemobi</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mantendo seus segredos seguros com AWS Secrets Manager]]></title>
            <link>https://medium.com/bemobi-tech/mantendo-seus-segredos-seguros-com-aws-secrets-manager-ecff68fac9c3?source=rss-e34c8a4e6294------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecff68fac9c3</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[aws-secrets-manager]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Jamal On the Code]]></dc:creator>
            <pubDate>Wed, 27 Feb 2019 15:23:58 GMT</pubDate>
            <atom:updated>2019-02-27T15:23:58.375Z</atom:updated>
            <content:encoded><![CDATA[<p>Gerencie seus segredos, auditagem, rotação, fácil de utilizar e barato. Conheça o AWS Secrets Manager.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Tkrnz6pPvUFuvSKxKUZCOQ.jpeg" /><figcaption>Ricky_and_Morty.jpg</figcaption></figure><p>Sempre que penso em um software que necessita gerenciar senhas, me desafio a melhorar a cada vez mais a forma que gerencio e obtenho minhas senhas. Confesso que manter as senhas seguras, nem sempre foi minha primeira prioridade durante o desenvolvimento de um software. Durante muito tempo foi comum para mim a utilização de um arquivo de propriedades com a senha de banco ou adminstração de alguma plataforma ou até mesmo criar uma planilha onde somente as pessoas do time tem acesso e passar como variável de ambiente em dado momento da entrega… Essas foram só alguma das muitas formas que já provi algum tipo de senha.</p><p>Com o tempo, conheci o HashiCorp Vault. O Vault é simples de usar, mas você precisa gerenciar um servidor para executá-lo como serviço. Se você tem uma equipe para fazer isso, incrível! Mas se você como eu não tem, é um risco que as vezes não queremos correr... Caso contrário, toda a sua aplicação, que depende disso, falhará. Em abril, obtive uma opção melhor com o lançamento do AWS Secrets Manager.</p><p>Para seguir em frente, presumo que você tenha algum conhecimento da AWS e da CLI que a mesma oferece. Se você não tiver, sugiro começar <a href="https://aws.amazon.com/getting-started/">aqui</a>.</p><p><em>É importante frisarmos que ao ler a palavra </em><strong><em>segredo</em></strong><em>, entende-se por qualquer tipo de credencial que seja sensível, como: senhas de banco, tokens de autenticação, senhas de criptografia, etc.</em></p><h3>AWS Secrets Manager</h3><p>Em abril de 2018, a AWS lançou o serviço Secrets Manager para gerenciar, auditar e girar segredos. É um serviço simples da AWS que custa apenas $ 0,40 por segredo por mês, com um adicional de $0,05 por 10.000 chamadas de API. É quase de graça manter suas senhas seguras e o serviço mais barato para manter e gerenciar senhas.</p><h4>Creating a secret</h4><p>Avançando no AWS Management Console, selecione o serviço Secrets Manager para criar um novo segredo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*jhhj92M9MdqK1pkp8tDWDA.png" /></figure><p>Já dentro do painel do serviço Secrets Manager, selecione “armazenar novo segredo” e em seguida a caixa “Outros tipos de segredos” e configure um novo segredo como abaixo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*HN_ile_X8nntprttKAiQcA.png" /></figure><p>Caso queria fazer pela AWS CLI, conseguimos obter o mesmo resultado com o comando a seguir.</p><pre>$ aws secretsmanager create-secret --name meusupersegredo --description &quot;que segredo?&quot; --secret-string file://minhas_credenciais.json</pre><p>Dentro do arquivo <strong>minhas_credenciais.json</strong>, temos um objeto JSON com os campos que representam minhas credenciais. Seguindo nosso exemplo, nosso <strong>minhas_credenciais.json</strong> deve ter o seguinte conteúdo:</p><pre>{&quot;apikey&quot;:&quot;meu_segredo_incrivel&quot;}</pre><p>Como você pode ver, podemos adicionar quantas linhas forem necessárias e criar três tipos de segredos. Mas, para o nosso propósito, selecionamos “Outros tipos de segredos” e avançamos clicando no botão “Avançar”. Clicando em “avançar”, apenas definimos o nome do nosso segredo, que será usado posteriormente para recuperá-lo dentro da nossa conta. Vamos nomear nosso segredo como <strong>meusupersegredo. </strong>Finalmente iremos recuperar nosso segredo programaticamente. O exemplo abaixo se encontra em <strong>Golang</strong>.</p><pre><strong>package </strong>main</pre><pre><strong>import </strong>(<br>   &quot;github.com/aws/aws-sdk-go/aws/session&quot;<br>   &quot;github.com/aws/aws-sdk-go/service/secretsmanager&quot;<br>   &quot;fmt&quot;<br>)</pre><pre><strong>func </strong>main() {<br>   sn := &quot;<strong>meusupersegredo</strong>&quot;<br>   s := session.Must(session.NewSession())<br>   sm := secretsmanager.New(s)</pre><pre>output, err := sm.GetSecretValue(&amp;secretsmanager.GetSecretValueInput{SecretId: &amp;sn})<br>   <strong>if </strong>err != nil {<br>      panic(err.Error())<br>   }</pre><pre>fmt.Println(*output.SecretString)<br>}</pre><p>Esta é uma maneira super simples de obter o nosso segredo e usá-lo, desta forma você precisa configurar suas credenciais da AWS antes de executar o exemplo de código acima.</p><h4>Fazendo auditoria dos seus segredos</h4><p>Um dos recursos do Secrets Manager é a auditoria de seus segredos citados pela AWS:</p><blockquote>(…) O AWS Secrets Manager permite auditar e monitorar segredos por meio da integração com os serviços de registro em log, monitoramento e notificação da AWS. Por exemplo, depois de habilitar o AWS CloudTrail em uma região da AWS, você pode auditar quando um segredo é armazenado ou alternado visualizando os logs do AWS CloudTrail. De forma semelhante, você pode configurar o Amazon CloudWatch para receber mensagens de e-mail usando o Amazon Simple Notification Service os segredos não são usados por um período. Ou configurar o Amazon CloudWatch Events para receber notificações por push quando o Secrets Manager alterna os segredos.</blockquote><h4>Conclusão</h4><p>Mais uma vez, a AWS lançou um serviço incrível para resolver problemas de segurança reais de nosso dia a dia, como você pode ver, é simples, fácil de usar e de baixo custo. Certamente, temos softwares opcionais, como o Vault mas neste ponto, sabemos que os serviços sólidos fornecidos pela AWS podem minimizar os danos na produção durante os momentos de crise. Dê sua opinião e sugestões sobre este artigo, será um prazer conversar sobre.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecff68fac9c3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bemobi-tech/mantendo-seus-segredos-seguros-com-aws-secrets-manager-ecff68fac9c3">Mantendo seus segredos seguros com AWS Secrets Manager</a> was originally published in <a href="https://medium.com/bemobi-tech">Bemobi</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Keeping your secrets safe with AWS Secrets Manager]]></title>
            <link>https://medium.com/jamalsoliva/keeping-your-secrets-safe-with-aws-secrets-manager-55e8e186abef?source=rss-e34c8a4e6294------2</link>
            <guid isPermaLink="false">https://medium.com/p/55e8e186abef</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[password-management]]></category>
            <category><![CDATA[cloud-services]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Jamal On the Code]]></dc:creator>
            <pubDate>Mon, 19 Nov 2018 19:18:39 GMT</pubDate>
            <atom:updated>2018-11-20T13:03:38.317Z</atom:updated>
            <content:encoded><![CDATA[<h3>Keeping Secrets with AWS Secrets Manager</h3><p>Secrets management, audit, rotation, easy to use and cheap. AWS Secrets Manager</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h-qv018JkotyGWquC5N3Yw.jpeg" /><figcaption>Secrets of a horseman.</figcaption></figure><p>Whenever I think about a software that manages credentials, I try to keep in mind how I can manage my production credentials safe and easy to use. I confess that keeping the passwords safe, wasn’t always my first priority during software projects. I used to write the passwords in configuration properties (it is quite common in projects), and for a long time I believed that was “safe”, until someones introduced me Hashicorp Vault, a platform for &quot;secrets&quot; management and data protection.</p><p>Vault is simple to use, but you need to manage a server to run it as service. If you have a team to do this, awesome! But if you don’t, like me, you need to make sure that it will never be down or unavailable. Otherwise, all your application, which depends on that, will break down. In April, I got a better option with release of AWS Secrets Manager.</p><p>To move forward, I will assume that you have an AWS Account and AWS CLI knowledge. If you don’t, I suggest getting started <a href="https://aws.amazon.com/getting-started/">here</a>.</p><h3>AWS Secrets Manager</h3><p>In April, AWS released Secrets Manager service to manage, audit and rotate secrets. It is a simple AWS service that only costs $0.40 per secret per month with an additional of $0.05 per 10,000 API calls. It is almost free to keep your passwords safe, and the cheapest service to maintain and manage passwords.</p><h4>Creating a secret</h4><p>Moving forward inside AWS Management Console, select Secrets Manager service to create a new secret.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*j_ZnB4b7QADy785dFsvnsw.png" /></figure><p>Inside Secrets Manager Console, select <em>“store new secret”</em>. Select the box “<em>Other types of secrets”</em> and configure a new secret as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TjRG-SoLAHSXza3cujpBVw.png" /></figure><p>With AWS CLI we can accomplish the same as above with the following command.</p><pre>$ aws secretsmanager create-secret --name myamazingsupersecret --description &quot;It is just a test&quot; --secret-string file://mycreds.json</pre><p>Inside <strong>mycreds.json</strong> we have a JSON object with the fields representing my credentials. Following our example our mycreds.json should have the following content:</p><pre>{&quot;apikey&quot;:&quot;mysupersecret&quot;}</pre><p>As you can see, we can add as many rows as we need and create three types of secrets. But for our purpose, we select “<em>Other types of secrets</em>” and move forward by clicking on the “<em>Next</em>” button. By clicking next we only set our secret&#39;s name, which will be used to find our secret inside our account. Let&#39;s name our secret as <strong>myamazingsupersecret</strong>. The next step is the rotation configuration that we skip it now.</p><p>At the final stage, we have the revision and samples of how we can get these credentials. I will use the GoLang example.</p><pre><strong>package </strong>main</pre><pre><strong>import </strong>(<br>   &quot;github.com/aws/aws-sdk-go/aws/session&quot;<br>   &quot;github.com/aws/aws-sdk-go/service/secretsmanager&quot;<br>   &quot;fmt&quot;<br>)</pre><pre><strong>func </strong>main() {<br>   sn := &quot;<strong>myamazingsupersecret</strong>&quot;<br>   s := session.Must(session.NewSession())<br>   sm := secretsmanager.New(s)</pre><pre>   output, err := sm.GetSecretValue(&amp;secretsmanager.GetSecretValueInput{SecretId: &amp;sn})<br>   <strong>if </strong>err != nil {<br>      panic(err.Error())<br>   }</pre><pre>   fmt.Println(*output.SecretString)<br>}</pre><p>This is a super simple way to get our secret and using it this way you need to configure your AWS Credentials before running the main above.</p><h4>Auditing your secret</h4><p>One of the Secrets Manager&#39;s feature is the audit of your secrets as cited by AWS:</p><blockquote>(…) through integration with AWS logging, monitoring, and notification services. For example, after enabling AWS CloudTrail for an AWS region, you can audit when a secret is stored or rotated by viewing AWS CloudTrail logs. Similarly, you can configure Amazon CloudWatch to receive email messages using Amazon Simple Notification Service when secrets remain unused for a period, or you can configure Amazon CloudWatch Events to receive push notifications when Secrets Manager rotates your secrets.</blockquote><h4>Conclusion</h4><p>Once again, AWS launched an incredible service to solve real applications&#39; security problems and as you can see it is simple, easy to use and low cost. Certainly, we have optional softwares such as Vault, but at this point, we know the solid services that AWS provides can minimize damages on production during crises moments.</p><p>Give your feedback and suggestions about this article. It will be a pleasure to discuss. I hope you enjoyed!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55e8e186abef" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jamalsoliva/keeping-your-secrets-safe-with-aws-secrets-manager-55e8e186abef">Keeping your secrets safe with AWS Secrets Manager</a> was originally published in <a href="https://medium.com/jamalsoliva">fernandosoliva</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring Cloud Config Server with Multiples Repositories]]></title>
            <link>https://medium.com/jamalsoliva/spring-cloud-config-server-with-multiples-repositories-d8aeaa5fc41c?source=rss-e34c8a4e6294------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8aeaa5fc41c</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[spring-framework]]></category>
            <category><![CDATA[spring-cloud]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Jamal On the Code]]></dc:creator>
            <pubDate>Mon, 18 Jun 2018 22:27:16 GMT</pubDate>
            <atom:updated>2018-09-04T12:43:42.784Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xoZF_Pj2_FTiKOUBQY3GLg.png" /><figcaption>Hey man, show me what you got!</figcaption></figure><p>It is a fast overview about Spring Cloud Config Server and one of most useful features for me in this service, multiple repositories as property source. Spring Cloud Config Server uses a git repository as property source or a file in your file system. The client can fetch configurations through a simple HTTP GET request. Java developers using Spring Framework can use the configuration client as you can see <a href="https://spring.io/guides/gs/centralized-configuration/">here</a>.</p><h4>The Config Server</h4><p>First of all we need our server working. To simplify I prepare a <a href="https://github.com/solivaf/sc-config-server-example">git repository with the Config Server pre configured</a> or you can use this docker image jonthecode/config-server-example to run a simple example. To run a new config server from scratch you can use the <a href="https://cloud.spring.io/spring-cloud-config/">Spring Getting Started</a>, it is very easy.</p><p>As said before the properties will be fetch from a git repository so let’s configure that.</p><p>First of all you will need clone the repository running in your terminal <strong><em>git clone https://github.com/solivaf/sc-config-server-example.git . </em></strong>After cloning the project you will find a file named application.yml in y <strong>src/main/resources/</strong>. This file has the app configuration as server port and repository URL.</p><pre># application.yml</pre><pre><strong>spring:<br>  cloud:<br>    config:<br>      server:<br>        git:<br>          uri: </strong>https://github.com/solivaf/config-properties-foo</pre><p>Navigate to repository URL you will find a repository with three configuration files: application.yml, application-prod.yml and config.properties.</p><p>Let’s see how it works. Run the command below:</p><pre>$ mvn spring-boot:run</pre><p>And performing the command</p><pre>$ curl localhost:8080/message-dev.properties<br>bar.foo: testDevPropertiesYml<br>foo.bar: testDevProperties</pre><p>Or</p><pre>$ curl localhost:8080/application-prod.yml<br>bar:<br>  foo: testProdPropertiesYml</pre><p>Or even using the pattern {application}/{profile} as you can see below</p><pre>$ curl localhost:8080/fooapp/prod<br>{<br>  &quot;name&quot;: &quot;fooapp&quot;,<br>  &quot;profiles&quot;: [<br>    &quot;dev&quot;<br>  ],<br>  &quot;label&quot;: null,<br>  &quot;version&quot;: &quot;430031ed47d68d5e1681095f091e9bde9bb07515&quot;,<br>  &quot;state&quot;: null,<br>  &quot;propertySources&quot;: [<br>    {<br>      &quot;name&quot;: &quot;<a href="https://github.com/solivaf/config-properties-foo/application-dev.yml">https://github.com/solivaf/config-properties-foo/application-dev.yml</a>&quot;,<br>      &quot;source&quot;: {<br>        &quot;bar.foo&quot;: &quot;testDevPropertiesYml&quot;<br>      }<br>    },<br>    {<br>      &quot;name&quot;: &quot;<a href="https://github.com/solivaf/config-properties-foo/application.yml">https://github.com/solivaf/config-properties-foo/application.yml</a>&quot;,<br>      &quot;source&quot;: {<br>        &quot;bar.foo&quot;: &quot;testPropertiesYml&quot;<br>      }<br>    }<br>  ]<br>}</pre><p>In this last request we got a long response. By default, spring will return the application-{profile}.yml file and the default file if these file exists.</p><p>But can we use more than one repository for config server instance? Let’s see.</p><h4>Config Server with Multiples Repositories</h4><p>If you run the config server you will realized that is a small and very simple application but imagine if we have 15 applications and they don’t share the same repository. Now with the we have until we need deploy 15 config server instances, one for each application.</p><p>The Spring Cloud Config Server provides a configuration with multiples repositories and they can be accessed by url like the first example. The config server will fetch each configuration by a pattern, so your label {application} in the path will be the key to find the correct repository. Let’s configure our application.yml in our config server.</p><p>Until now we have this application.yml:</p><pre><strong>spring:<br>  cloud:<br>    config:<br>      server:<br>        git:<br>          uri: </strong>https://github.com/solivaf/config-properties-foo</pre><p>Now we should add our additional repositories as you can see below:</p><pre><strong>spring:<br>  cloud:<br>    config:<br>      server:<br>        git:<br>          uri: </strong>https://github.com/solivaf/config-properties-foo<br>          <strong>repos:<br>            appFoo:<br>              pattern: app-foo<br>              uri: </strong>https://github.com/solivaf/config-properties-bar</pre><p>Restart the config server and perform the requests below.</p><pre>$ curl localhost:8080/fooapp/prod<br>{<br>  &quot;name&quot;: &quot;fooapp&quot;,<br>  &quot;profiles&quot;: [<br>    &quot;prod&quot;<br>  ],<br>  &quot;label&quot;: null,<br>  &quot;version&quot;: &quot;8686fb74f9af0aead98bd20d6e20e84a37028781&quot;,<br>  &quot;state&quot;: null,<br>  &quot;propertySources&quot;: [<br>    {<br>      &quot;name&quot;: &quot;<a href="https://github.com/solivaf/config-properties-foo/application-prod.yml">https://github.com/solivaf/<strong>config-properties-foo</strong>/application-prod.yml</a>&quot;,<br>      &quot;source&quot;: {<br>        &quot;bar.foo&quot;: &quot;testProdPropertiesYml&quot;<br>      }<br>    },<br>    {<br>      &quot;name&quot;: &quot;<a href="https://github.com/solivaf/config-properties-foo/application.yml">https://github.com/solivaf/<strong>config-properties-foo</strong>/application.yml</a>&quot;,<br>      &quot;source&quot;: {<br>        &quot;bar.foo&quot;: &quot;testPropertiesYml&quot;<br>      }<br>    }<br>  ]<br>}</pre><p>Now we can see the repository used to application <strong>fooapp</strong>, as we don’t have any pattern mapped to this application, the config server will use the default app, now if we specify the pattern <strong>app-foo</strong> which is mapped in our config-server property file we should get another repository as response.</p><pre>$ curl localhost:8080/app-foo/prod<br>{<br>  &quot;name&quot;: &quot;app-foo&quot;,<br>  &quot;profiles&quot;: [<br>    &quot;prod&quot;<br>  ],<br>  &quot;label&quot;: null,<br>  &quot;version&quot;: &quot;f34ced0565042be4cf87c937c1dab2703e0b8ed2&quot;,<br>  &quot;state&quot;: null,<br>  &quot;propertySources&quot;: [<br>    {<br>      &quot;name&quot;: &quot;<a href="https://github.com/solivaf/config-properties-bar/app-foo-prod.yml">https://github.com/solivaf/<strong>config-properties-bar</strong>/app-foo-prod.yml</a>&quot;,<br>      &quot;source&quot;: {<br>        &quot;foo.bar&quot;: &quot;testProdPropertiesYml&quot;<br>      }<br>    },<br>    {<br>      &quot;name&quot;: &quot;<a href="https://github.com/solivaf/config-properties-bar/application-prod.yml">https://github.com/solivaf/<strong>config-properties-bar</strong>/application-prod.yml</a>&quot;,<br>      &quot;source&quot;: {<br>        &quot;foo.bar&quot;: &quot;testProdPropertiesYml&quot;<br>      }<br>    },<br>    {<br>      &quot;name&quot;: &quot;<a href="https://github.com/solivaf/config-properties-bar/application.yml">https://github.com/solivaf/<strong>config-properties-bar</strong>/application.yml</a>&quot;,<br>      &quot;source&quot;: {<br>        &quot;foo.bar&quot;: &quot;testPropertiesYml&quot;<br>      }<br>    }<br>  ]<br>}</pre><p>Now, we have the correct repository which was mapped in our property file and all files which represents our <strong>app-foo</strong> application. The response order represents the hierarchy of the file being the most priority the first file in the list.</p><h4>That’s It!</h4><p>As simple as it can be, Spring Config Server helps a lot when we you manage a lot of configuration properties. It is easy to use and deploy and not only Java developers can use this service.</p><p>I hope this short story could help you in some way. See you in the next short story.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8aeaa5fc41c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jamalsoliva/spring-cloud-config-server-with-multiples-repositories-d8aeaa5fc41c">Spring Cloud Config Server with Multiples Repositories</a> was originally published in <a href="https://medium.com/jamalsoliva">fernandosoliva</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git Workflows: Centralized, Featured Branch and Git Flow]]></title>
            <link>https://medium.com/jamalsoliva/git-workflows-centralized-featured-branch-and-git-flow-52ebb4efd3db?source=rss-e34c8a4e6294------2</link>
            <guid isPermaLink="false">https://medium.com/p/52ebb4efd3db</guid>
            <category><![CDATA[version-control]]></category>
            <category><![CDATA[management]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Jamal On the Code]]></dc:creator>
            <pubDate>Sat, 06 May 2017 20:16:52 GMT</pubDate>
            <atom:updated>2017-05-06T20:16:52.544Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>You will not found a solution for all your problems with only one of these workflows, instead you will see very important options to work with Git in your team.</blockquote><p>Patterns are always important. We’ve been used to it since we were born. Patterns facilitates to recognize what is and how something works… In development we are <strong>officially</strong> using it since Erich Gamma, Ralph Johnson and others wrote the book <strong>Design Patterns: Elements of Reusable Object-Oriented Software. </strong>This book describe a lot of patterns for development to organinzing code, create responsabilities between resources (a.k.a code), decomposition, inheritance, polymorphism and others benefits.</p><p>When we thought about version control <strong>Git</strong> is the most popular <a href="https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control"><strong>VCS</strong></a><strong> </strong>nowadays. It was created in 2005 and since then he is marked by his flexbility, facility and a lot of options to work in a team on the same repository of code. Git has patterns (good ones) to work with, they are: <strong>Centralized Workflow, Featured Branch Workflow, Gitflow Workflow and Forking Workflow. </strong>I will talk a bit more about the first three.</p><h3>Centralized Workflow</h3><p>This is the “<strong>troublemaker</strong>”, the cause of discords. The Centralized Workflow uses a central repository to serve as the entry for all changes to the project. The default development branch is called master and all changes are committed into this branch. This workflow doesn’t require any other branches besides master. The client starts by cloning the central repository and in their own local copies of the project, they edit files and commit changes as they would with SVN; however, these new commits are stored locally completely isolated from the central repository. This lets developers defer synchronizing upstream until they’re at a convenient break point. It is the most simple way to work with Git, you work directly on the master locally and when you finish doing changes you commit to the central repository, simple right? Not too simple, let’s see the big picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*i66b1G8VBnxKnKQKs1socg.png" /><figcaption>Example of centralized workflow. (image from: Atlassian.com)</figcaption></figure><p>Imagine that you have a team and everyone is working on your local copy of master and one of your teammates, John, push all his changes about the feature B to the central repository but you are working on feature A locally yet. Friday’s you finish your feature and your leader tells you to deploy on production this feature as soon as posible, BUT the John’s feature cannot be deployed together. See the big picture? You have to sincronize your local repository with master to deploy something but in master you have code who is not applicable to be deployed. It will be cool if you can work on “another copy of central repository”, right? Featured Branch and Git Flow solve your problem, let’s see more.</p><h3>Featured Branch Workflow.</h3><p>The Feature Branch Workflow still uses a central repository, and master still represents the official project history. But, instead of committing directly on their local master branch, developers create a new branch every time they start work on a new feature. Feature branches should have descriptive names as <em>login-template-header, login-http-resource, refactoring-login-service</em>, etc.</p><p>Now youre team is working alongside of the remote master branch, everyone is working on a feature branch. When each feature is done and are up to put on development the branch should be merged with remote master by a <strong>Pull Request</strong>.</p><h4>Pull Request.</h4><p>Pull requests are a feature that makes it easier for developers to collaborate using a git client (GitHub, Bitbucket, Stash, etc.). They provide a user-friendly web interface for discussing proposed changes before integrating them into the official project. Pull request is a dedicated forum for discussing the proposed feature. If there are any problems with the changes, teammates can post feedback in the pull request and even tweak the feature by pushing follow-up commits. All of this activity is tracked directly inside of the pull request.</p><p>Essentially a PR should be closed after a Code Review with others developers. Code review is a major benefit of pull requests, but they’re actually designed to be a generic way to talk about code. You can think of pull requests as a discussion dedicated to a particular branch. This means that they can also be used much earlier in the development process. For example, if a developer needs help with a particular feature, all they have to do is file a pull request. Interested parties will be notified automatically, and they’ll be able to see the question right next to the relevant commits. After the Code Review is finished your code will be able to become part of the remote master code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*a4XW5b9nPVIL7V75m-CQ0w.png" /><figcaption>Example how PR works. (Atlassian.com)</figcaption></figure><h3><strong>Git Workflow.</strong></h3><p>This is the most complete workflow on git, you have many possibilites. I always thought this is the exactly workflow which big teams work on the same repository would adopt and the small teams should avoid.</p><p>Git Flow was presented by <a href="http://nvie.com/about/">Vincent Driessen</a> in the article <a href="http://nvie.com/posts/a-successful-git-branching-model/">A successful Git branching model</a> in 2010 and looks like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-iPjLlSJKY3ifHae.png" /><figcaption>Git Flow presented at nvie.com</figcaption></figure><p>Looking the big picture you can see the possibilities you can do with this flow. You have hotfixes branch that should be solved as soon as posible on the minor “distance” of master, to simplify and do the change as faster as can, you have release branchs which are the preparation to the next release on production, develop branch and as you can note by the name is on the code merged from release branch are, nothing directly on master anymore, which now is only tags.</p><p>I guess this is the most “beautiful” workflow on git, you have a big consistency working with a big team but is an overengineering when you are working in a small or medium (maybe) team, because you have more control to manage the changes.</p><p>Git Flow is an evolution of Featured Branch Workflow, so it reuse all principles of each pattern and include more as develope, hotfixes and release branchs.</p><p>These patterns are very important and I guess for each team you will use one of them. One isn’t better them another in every case, forget it! You will not found a solution for all your problems with only one of them instead you will have more options to work with small, medium and big teams and see how any of these patterns works better.</p><p>I hope you have enjoyned! If not comment or send me private message on <a href="http://twitter.com/solivaf">Twitter</a> with suggestions. Below has some useful links of this topics.</p><p><a href="http://nvie.com/posts/a-successful-git-branching-model/">A successful Git branching model</a> by <a href="http://nvie.com/about/">Vincent Driessen</a></p><p><a href="https://www.atlassian.com/git/tutorials/comparing-workflows">Comparing Workflows</a> by <a href="https://www.atlassian.com/git/tutorials">Atlassian</a></p><p><a href="https://www.atlassian.com/git/tutorials/making-a-pull-request">Making a Pull Request</a> by <a href="https://www.atlassian.com/git/tutorials">Atlassian</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52ebb4efd3db" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jamalsoliva/git-workflows-centralized-featured-branch-and-git-flow-52ebb4efd3db">Git Workflows: Centralized, Featured Branch and Git Flow</a> was originally published in <a href="https://medium.com/jamalsoliva">fernandosoliva</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reduce the impact moving to language X to Y.]]></title>
            <link>https://medium.com/@fernandosolivas/reduce-the-impact-moving-to-language-x-to-y-df4d27ef2294?source=rss-e34c8a4e6294------2</link>
            <guid isPermaLink="false">https://medium.com/p/df4d27ef2294</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Jamal On the Code]]></dc:creator>
            <pubDate>Mon, 24 Apr 2017 23:53:14 GMT</pubDate>
            <atom:updated>2017-04-25T00:00:16.177Z</atom:updated>
            <content:encoded><![CDATA[<h3>Reduce the impact moving from language X to Y.</h3><blockquote>“Sometimes it takes a step back then two steps forward.” — The Frog of the Well</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*L6CYFcd3yT-WjLwJBBSdPQ.jpeg" /></figure><p>If you are reading to compare two languages, this is not about that, it is about something that I consider bigger. It is my experience about analyze before make a decision, when you want implement a new development environment to a team. This is my experience in how we manage a migration of programming language in our application and why we do that.</p><h3>Motivation — Go x Java environment.</h3><p>We move from <strong>Go</strong> to <strong>Java.</strong> Why? In first place the change was nothing about performance. I know the most of articles comparing two languages involves performance, benchmarks, lexical comparisons and more so I decide to move into something very important too, the team skill.</p><p>When you are working in a team you can’t make decisions based only in the best language or architecture to your case, you should combine this with your team skill and the risks of maintenance.</p><blockquote>If you want implement a new language to a team that don’t have the knowledge yet consider do tech talks, dojo about that technology and implement a small P.O.C with your team, it is a good way to tech a new technology.</blockquote><h3>The Case</h3><p>I am part of a team with 5 developers and the core knowledge is <em>Java</em>, <em>Spring</em>, <em>Apache Spark</em>, <em>Apache</em> <em>Kafka</em>, <em>AWS</em> and others tools.</p><p>Someday we had to built a service to consume messages from a <strong>Kafka</strong> and send to a <strong>REST</strong> client. It should be a small service only to be used by our team’s microservices, so we decide to develop this in <strong>Go</strong> language because the application was about concurrency, should be a lightweight and <em>to implement a new language to our team.</em></p><p>The application design and architecture was good enough to accomplish what we wanted technically, for each client we had a <strong>Docker</strong> container to prevent one service from influencing the other, that wasn’t make sane to our scope.</p><p>After deploying our service in production and showing to our company what we accomplished they realize that this solution would work for the whole company. The work to do to configure new clients was minimum, we only need the client URL to send the message processed from <strong>Kafka</strong> and run a <strong>Docker</strong> image for this client.</p><p>After all work done we deploy on production and everything works fine, any code change was necessary. So, everything looks good… Why should we move to another language? That was the first thing in my mind when my leader ask me to change the application to a Java version and I realized… We had a team without solid knowledge in Go but had in Java and as you can see the application doesn’t serve only our team anymore but the whole company. If we had any problems with this app we had to solve fast as we can and in that moment with Go it was not possible, obviously not because the language but because our team profile, we had only one developer with solid knowledge in Go, so I start to move to a Java environment.</p><h3>Starting the migration.</h3><p>Before start a new project we created the minimum requirements to approve these changes.</p><ol><li>We had to accomplish the same metrics about resources that we had in Go version, or at least we should stay close. (CPU Usage, Memory Usage, Net In, Net Out…)</li><li>We had to parallel the partitions in Kafka to process each message, that way we could guarantee the offset consistency (see how Apache Kafka Client 0.10.0 works).</li><li>We can not change the message or the message order to send to the REST client.</li><li>We had to coverage at least 80% of our cases with test.</li></ol><p>We used parallelStream from Java 8 to run with 64+ threads, it was the best solution in our benchmarks with many threads. We need at least 64 threads, 1 for each partition in our Kafka topic. We migrate from <strong>SLF4J 1.7.2</strong> to <strong>Log4J 2.5 </strong>with<strong> Log4jContextSelector</strong> to logging asynchronously and others features to accomplish our requirements.</p><p>When we finish our Sprint and we had the Java version ready for tests to compare with Go version We run it in the same AWS EC2 instance that Go version was running and the same outputs in resources usages, except in <em>Network In</em> where we had a increase of 30% because we poll a number greater than in Go version, was found.</p><h3>The migration result.</h3><p>After all work done we had a application version that all team could maintain (Java) and a version that can be implemented to our team’s microservices (Go) which have small impact. That way when we have a change to do in Go version we will be more comfortable and we can give the team the opportunity to learn something new and have another language in our toolbox to use in new solutions without having to redo all this work.</p><blockquote>This is all about to analyze when you have a good call and when it is a trap move to an unknown environment.</blockquote><p>We could stay with our Go version and take the risk, this solution sometimes is the first option. Software Developers has the behavior and the hungry to learn something new and that is awesome but is wise <em>step back and then two step forwards</em>. Stay alert to don’t be caught by the trap on <a href="https://blog.daftcode.pl/hype-driven-development-3469fc2e9b22"><strong>Hype Driven Development (HDD)</strong></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df4d27ef2294" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>