<?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: Charles Scholle</title>
    <description>The latest articles on DEV Community by Charles Scholle (@chaz8080).</description>
    <link>https://dev.to/chaz8080</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%2F977974%2F6e8457b4-3d7a-4ce6-9ff0-17c30c85d699.jpeg</url>
      <title>DEV Community: Charles Scholle</title>
      <link>https://dev.to/chaz8080</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chaz8080"/>
    <language>en</language>
    <item>
      <title>Git Smart: Streamlining Your Workflow with the prepare-commit-msg Hook</title>
      <dc:creator>Charles Scholle</dc:creator>
      <pubDate>Sun, 26 Feb 2023 04:00:23 +0000</pubDate>
      <link>https://dev.to/chaz8080/git-smart-streamlining-your-workflow-with-the-prepare-commit-msg-hook-432p</link>
      <guid>https://dev.to/chaz8080/git-smart-streamlining-your-workflow-with-the-prepare-commit-msg-hook-432p</guid>
      <description>&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;If you want to learn how to improve and automate your commit messages, you're in the right place!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Motivation&lt;/li&gt;
&lt;li&gt;Setting up the prepare-commit-msg hook&lt;/li&gt;
&lt;li&gt;Configure the hook globally&lt;/li&gt;
&lt;li&gt;Configure existing repositories&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

&lt;p&gt;Most companies use an issue and project tracking software, such as JIRA, for software development. JIRA has integrations for many online VCSs. If you name your branches appropriately, then JIRA can automatically link to branches and pull requests created on many different code hosting platforms (GitHub, GitLab, Bitbucket, etc.)&lt;/p&gt;

&lt;p&gt;When several developers are working in parallel, merging branches becomes commonplace. It can be very helpful to prefix your commits with the ticket number. For instance, assume you're working on ticket &lt;code&gt;JIRA-1234&lt;/code&gt; and want to commit a change, you might want to do something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"JIRA-1234: add part of my awesome feature"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In theory, every commit could (and probably should) have this reference back to a ticket. If and when a someone needs more context around a commit, it provide the link to further documentation. However, since this is a manual process it can lead to a lack of uniformity and consistency.&lt;/p&gt;

&lt;p&gt;But fear not! Git's got your back with its &lt;code&gt;prepare-commit-msg&lt;/code&gt; hook.&lt;/p&gt;
&lt;h2&gt;
  
  
  Setting up the git hook
&lt;/h2&gt;

&lt;p&gt;Here's a painless one-liner to install the hook into an existing repository. Open a terminal, navigate to your repository, then run the following command:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl  https://gist.githubusercontent.com/chaz8080/36b539ca29a29de11334e57a9dd3b61d/raw/4f6dc9232346b7d866bcfc0fbcdd43b6fb638073/install-hook.sh | sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Here's what it's doing:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;It should add a &lt;code&gt;prepare-commit-msg&lt;/code&gt; file to your repo's &lt;code&gt;.git/hooks&lt;/code&gt; folder, and make it executable. &lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Assuming that you're on a branch named after the JIRA ticket, e.g. &lt;code&gt;JIRA-1234_my_awesome_feature&lt;/code&gt;, then you can simply commit your message as you normally would, without any ticket info:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"add another part of my awesome feature"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And the desired prefix will automatically be added. Running &lt;code&gt;git log&lt;/code&gt;, you should see something like:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;commit 8014201b6f223ca800c574bac093e53641c1bae9 &lt;span class="o"&gt;(&lt;/span&gt;HEAD -&amp;gt; JIRA-1234_my_awesome_feature&lt;span class="o"&gt;)&lt;/span&gt;
Author: John Smith &amp;lt;john.smith@gmail.com&amp;gt;
Date:   Sat Feb 25 21:05:22 2023 &lt;span class="nt"&gt;-0500&lt;/span&gt;

    JIRA-1234: add another part of my awesome feature
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Configure the hook globally
&lt;/h2&gt;

&lt;p&gt;Instead installing the hook in every new repo cloned, let's configure global templates and configure the global &lt;a href="https://git-scm.com/docs/git-clone#Documentation/git-clone.txt-inittemplateDir" rel="noopener noreferrer"&gt;init.templatedir&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Assuming that you do not already have templates set up, run the following command:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl  https://gist.githubusercontent.com/chaz8080/36b539ca29a29de11334e57a9dd3b61d/raw/d1768296cbd15d59149097b8f8840ac107399567/configure-git-template.sh | sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Again, a peek under the hood:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;This configures the global git template directory and installs the previous hook.&lt;/p&gt;

&lt;p&gt;This will configure a new directory &lt;code&gt;~/.git-template&lt;/code&gt;. Anytime that you initialize or clone a new repository, these templates will be copied over.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configure existing repositories
&lt;/h2&gt;

&lt;p&gt;Now that you know how to create a one off hook for a single repo, and how to make sure that all new repos get the same config, you might want a script to also add the &lt;code&gt;prepare-commit-msg&lt;/code&gt; hook to all of your existing repos.&lt;/p&gt;

&lt;p&gt;In terminal, and at the directory for which you store all of your repositories, simply run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://gist.githubusercontent.com/chaz8080/36b539ca29a29de11334e57a9dd3b61d/raw/95a196a6d01aeee505f4ac66f2ef6256b6ed7d3e/install-to-all-repos.sh | sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;For posterity, it simply searches all subdirectories for any git repositories and copies the &lt;code&gt;prepare-commit-msg&lt;/code&gt; that was previously configured in your global git template:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



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

&lt;p&gt;In conclusion, using the &lt;code&gt;prepare-commit-msg&lt;/code&gt; hook is a simple and effective way to improve the organization and readability of your Git commits, particularly in a collaborative development environment. By automatically prepending JIRA ticket numbers to commit messages, you can make it easier to track changes and tie them back to specific tickets or issues.&lt;/p&gt;

&lt;p&gt;Setting up the &lt;code&gt;prepare-commit-msg&lt;/code&gt; hook globally across your organization is easy and can be done with just a few simple steps. By following the instructions outlined in this article, you can ensure that all of your Git repositories have the hook installed and ready to use.&lt;/p&gt;

&lt;p&gt;I hope that this article has been helpful in guiding you through the process of setting up the &lt;code&gt;prepare-commit-msg&lt;/code&gt; hook and that you can start using it to improve your Git workflow today. Happy coding!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Local Kubernetes Playground Made Easy</title>
      <dc:creator>Charles Scholle</dc:creator>
      <pubDate>Fri, 20 Jan 2023 14:38:16 +0000</pubDate>
      <link>https://dev.to/chaz8080/local-kubernetes-playground-made-easy-4m10</link>
      <guid>https://dev.to/chaz8080/local-kubernetes-playground-made-easy-4m10</guid>
      <description>&lt;p&gt;Hey there! Are you looking to play around with Kubernetes but don't want to go through the hassle of setting up a cluster on the cloud? Well, you're in luck! In this blog post, I'm going to show you how to set up a local environment for experimenting with Docker and Kubernetes using &lt;a href="https://k3d.io/" rel="noopener noreferrer"&gt;k3d&lt;/a&gt;. We'll make sure you have all the necessary tools installed, and then I'll walk you through the process of creating a cluster and experimenting with it. So grab a cup of coffee (or tea) and let's dive in!&lt;/p&gt;

&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;If you are a developer and want to learn how to deploy applications to a cluster, getting a cluster up an running can be a daunting task in it's own rights. There are many ways to do it: spinning up local virtual machines and configuring from scratch or using tools like &lt;a href="https://minikube.sigs.k8s.io/docs" rel="noopener noreferrer"&gt;minikube&lt;/a&gt;, etc. You may not care for the pain of setting up and configuring a cluster, and if that is you, then the quickest way that I have found is using &lt;a href="https://k3d.io/" rel="noopener noreferrer"&gt;k3d&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-requisites
&lt;/h2&gt;

&lt;p&gt;For this tutorial, you'll need to have Docker, kubectl, and k3d installed. &lt;br&gt;
&lt;strong&gt;If you are on a Mac and have &lt;a href="https://brew.sh/" rel="noopener noreferrer"&gt;brew&lt;/a&gt; installed, you can simply run the install command(s) for anything missing:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;docker 
brew &lt;span class="nb"&gt;install &lt;/span&gt;kubernetes-cli 
brew &lt;span class="nb"&gt;install &lt;/span&gt;k3d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Otherwise, see the respective docs for install instructions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.docker.com/products/docker-desktop" rel="noopener noreferrer"&gt;Docker&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kubernetes.io/docs/tasks/tools/install-kubectl/" rel="noopener noreferrer"&gt;kubectl&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/rancher/k3d" rel="noopener noreferrer"&gt;k3d&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Create a Cluster
&lt;/h2&gt;

&lt;p&gt;Here is the best part! &lt;a href="https://k3d.io/" rel="noopener noreferrer"&gt;k3d&lt;/a&gt; is a wrapper around &lt;a href="https://github.com/k3s-io/k3s" rel="noopener noreferrer"&gt;k3s&lt;/a&gt; and can set up your entire cluster using Docker in no time. It should be noted that this is not intended for production, but it is intended for tinkerers, learning, and exam prep. Here's an example command and then we will break it down:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;k3d cluster create my-cluster &lt;span class="nt"&gt;--agents&lt;/span&gt; 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This sets up a new cluster with one server for the control plan and 3 worker nodes. After a short period, you should be able to run &lt;code&gt;kubectl get node&lt;/code&gt; and them: one server (control-plane/master) as well as 3 worker nodes, e.g.:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;❯ kubectl get node                         
NAME                      STATUS   ROLES                  AGE    VERSION
k3d-my-cluster-agent-0    Ready    &amp;lt;none&amp;gt;                 108s   v1.24.6+k3s1
k3d-my-cluster-server-0   Ready    control-plane,master   116s   v1.24.6+k3s1
k3d-my-cluster-agent-2    Ready    &amp;lt;none&amp;gt;                 112s   v1.24.6+k3s1
k3d-my-cluster-agent-1    Ready    &amp;lt;none&amp;gt;                 112s   v1.24.6+k3s1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to blow it away, simply run &lt;code&gt;k3d cluster delete my-cluster&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;At this point, you have a functioning Kubernetes cluster that you can spin up or delete in seconds, running locally with no external dependencies!&lt;/p&gt;

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

&lt;p&gt;While there are many ways to spin up a Kubernetes cluster, &lt;a href="https://k3d.io/" rel="noopener noreferrer"&gt;k3d&lt;/a&gt; is by far one of the simplest.&lt;/p&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>Function URLs and Keeping AWS Lambda Warm and Healthy</title>
      <dc:creator>Charles Scholle</dc:creator>
      <pubDate>Fri, 13 Jan 2023 22:20:42 +0000</pubDate>
      <link>https://dev.to/chaz8080/function-urls-and-keeping-aws-lambda-warm-and-healthy-16le</link>
      <guid>https://dev.to/chaz8080/function-urls-and-keeping-aws-lambda-warm-and-healthy-16le</guid>
      <description>&lt;p&gt;The &lt;a href="https://github.com/Nuagic/terraform-aws-lambda-warmer"&gt;terraform-aws-lambda-warmer&lt;/a&gt; repository is a useful tool for keeping your AWS Lambda functions warm and reducing cold start latency. Recently, I discovered that Lambda functions now allow for &lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/lambda-urls.html"&gt;function URLs&lt;/a&gt; that can host a server over HTTPS without the need for additional tooling such as AWS Gateway, etc. These are perfect for behind the scenes APIs where you do not necessarily need a human friendly custom URL. With this in mind, I decided to &lt;a href="https://github.com/chaz8080/terraform-aws-lambda-warmer"&gt;fork the repository&lt;/a&gt; and make an update to the default event to call a &lt;code&gt;/health&lt;/code&gt; endpoint.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why call a &lt;code&gt;/health&lt;/code&gt; endpoint?
&lt;/h2&gt;

&lt;p&gt;Firstly, the &lt;a href="https://learn.microsoft.com/en-us/azure/architecture/patterns/health-endpoint-monitoring"&gt;health endpoint monitoring pattern&lt;/a&gt; is a widely employed technique, so if you move away from Lambda, it will not be wasted effort. Monitoring the health of your Lambda functions is crucial for ensuring that they're running smoothly and that any issues are caught quickly. By calling the health endpoint at regular intervals, you can check that your functions are running as expected and take action if they are not. This can help to prevent downtime and ensure that your users are getting the best possible experience.&lt;/p&gt;

&lt;p&gt;Additionally, calling a health endpoint also helps to keep the Lambda warm, reducing latency. Cold starts can be a major performance bottleneck, and by keeping your functions warm, you can ensure that they're ready to go when they're needed. Furthermore, emitting a CloudWatch event on failure can aid in monitoring, as it will trigger an alert and allow you to take action.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use the fork
&lt;/h2&gt;

&lt;p&gt;To use my &lt;a href="https://github.com/chaz8080/terraform-aws-lambda-warmer"&gt;fork of the repository&lt;/a&gt;, you'll need to set up the health endpoint and configure the warmer. Assuming that you are hosting your server on a Lambda function and deploying your function with terraform, here is an example to add the warmer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight terraform"&gt;&lt;code&gt;&lt;span class="k"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_lambda_function"&lt;/span&gt; &lt;span class="s2"&gt;"my_lambda_function"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;# Configuration for your Lambda function&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;module&lt;/span&gt; &lt;span class="s2"&gt;"my_lambda_function_warmer"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;source&lt;/span&gt;        &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://github.com/chaz8080/terraform-aws-lambda-warmer"&lt;/span&gt;
  &lt;span class="nx"&gt;function_name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_lambda_function&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;my_lambda_function_warmer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;function_name&lt;/span&gt;
  &lt;span class="nx"&gt;function_arn&lt;/span&gt;  &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_lambda_function&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;my_lambda_function_warmer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;arn&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your health endpoint's path is something other than &lt;code&gt;/health&lt;/code&gt;, then you can override the &lt;code&gt;input&lt;/code&gt; variable, such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight terraform"&gt;&lt;code&gt;&lt;span class="k"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_lambda_function"&lt;/span&gt; &lt;span class="s2"&gt;"my_lambda_function"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;# Configuration for your Lambda function&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;module&lt;/span&gt; &lt;span class="s2"&gt;"my_lambda_function_warmer"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;source&lt;/span&gt;        &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://github.com/chaz8080/terraform-aws-lambda-warmer"&lt;/span&gt;
  &lt;span class="nx"&gt;function_name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_lambda_function&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;my_lambda_function_warmer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;function_name&lt;/span&gt;
  &lt;span class="nx"&gt;function_arn&lt;/span&gt;  &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_lambda_function&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;my_lambda_function_warmer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;arn&lt;/span&gt;
  &lt;span class="nx"&gt;input&lt;/span&gt;         &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"{&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;body&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;:null,&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;httpMethod&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;:&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;GET&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;,&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;path&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;:&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;/api/v2/health&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;,&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;requestContext&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;:{}}"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will set up the resources to invoke your Lambda function every 5 minutes by default. See the other variables that can be overridden &lt;a href="https://github.com/chaz8080/terraform-aws-lambda-warmer/blob/main/variables.tf"&gt;here&lt;/a&gt;.&lt;/p&gt;

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

&lt;p&gt;By using &lt;a href="https://github.com/chaz8080/terraform-aws-lambda-warmer"&gt;this fork&lt;/a&gt;, you can keep your Lambda functions warm that are utilizing function URLs. I hope you find it useful and encourage you to try it out and provide feedback.&lt;/p&gt;

&lt;p&gt;It should be noted that &lt;a href="https://techcrunch.com/2022/11/28/aws-makes-lambda-cold-start-latency-a-thing-of-the-past-with-snapstart"&gt;SnapStart&lt;/a&gt; is a recent solution to the cold start issue as well, but appears to be limited to Java at the time of writing.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>lambda</category>
      <category>terraform</category>
    </item>
    <item>
      <title>Golang: Named Returns Are Useful!!!</title>
      <dc:creator>Charles Scholle</dc:creator>
      <pubDate>Tue, 29 Nov 2022 21:40:16 +0000</pubDate>
      <link>https://dev.to/chaz8080/golang-named-returns-are-useful-38ne</link>
      <guid>https://dev.to/chaz8080/golang-named-returns-are-useful-38ne</guid>
      <description>&lt;h1&gt;
  
  
  Named returns
&lt;/h1&gt;

&lt;p&gt;If you are not familiar with what a named return is, reference &lt;a href="https://go.dev/tour/basics/7" rel="noopener noreferrer"&gt;A Tour of Go Basics&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Named returns... Hurk...
&lt;/h2&gt;

&lt;p&gt;I know, I know... Named returns can decrease the readability of longer functions written in Golang, but there is a case in which they are a necessity. Handling panics gracefully!&lt;/p&gt;

&lt;h3&gt;
  
  
  Problem
&lt;/h3&gt;

&lt;p&gt;In many languages, you might use a try/catch block to handle some code that might otherwise throw an exception and wreak havoc. They allow us to override any values. In Golang, we have panics.&lt;/p&gt;

&lt;p&gt;First, let's create a simple function that divides 2 integers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;Divide&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The issue with this code is that we cannot divide by &lt;code&gt;0&lt;/code&gt;. Doing so will result in: &lt;code&gt;panic: runtime error: integer divide by zero&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We could have a check for whether the denominator is &lt;code&gt;0&lt;/code&gt;, but for the purposes of this post, how can we gracefully handle this panic?&lt;/p&gt;

&lt;h3&gt;
  
  
  Solution
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://go.dev/blog/defer-panic-and-recover" rel="noopener noreferrer"&gt;Here's a refresher on panic, defer, and recover.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By naming the return values, &lt;code&gt;val&lt;/code&gt; and &lt;code&gt;err&lt;/code&gt; respectively, we can recover from the panic and return any value and error we would like.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;Divide&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="kt"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;defer&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nb"&gt;recover&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;error&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;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, instead of needing to handle the panic everywhere &lt;code&gt;Divide&lt;/code&gt; is called, callers can simply handle the graceful error.&lt;/p&gt;

</description>
      <category>frontend</category>
      <category>javascript</category>
      <category>react</category>
      <category>community</category>
    </item>
  </channel>
</rss>
