<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>golo Archives | Clever Cloud</title>
	<atom:link href="https://stagingv6.cleverapps.io/blog/tag/golo/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>From Code to Product</description>
	<lastBuildDate>Tue, 17 Oct 2017 17:15:00 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2023/03/cropped-cropped-favicon-32x32.png</url>
	<title>golo Archives | Clever Cloud</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>One Framework a Day keeps the Boredom Away: Vert-X Golo</title>
		<link>https://stagingv6.cleverapps.io/blog/features/2017/10/17/1fdba-vertx-golo/</link>
		
		<dc:creator><![CDATA[Laurent Doguin]]></dc:creator>
		<pubDate>Tue, 17 Oct 2017 17:15:00 +0000</pubDate>
				<category><![CDATA[Features]]></category>
		<category><![CDATA[1fdba]]></category>
		<category><![CDATA[golo]]></category>
		<category><![CDATA[jvm]]></category>
		<category><![CDATA[vertx]]></category>
		<guid isPermaLink="false">https://www2.cleverapps.io/wp/blog/technology/2017/10/17/1fdba-vertx-golo/</guid>

					<description><![CDATA[<p><img width="1400" height="540" src="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" decoding="async" fetchpriority="high" srcset="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1.png 1400w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1-300x116.png 300w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1-1024x395.png 1024w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1-768x296.png 768w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1-1368x528.png 1368w" sizes="(max-width: 1400px) 100vw, 1400px" /></p><p>Welcome to this new edition of <a href="/blog/features/2017/10/09/1fdba-step0/">One Framework a Day keeps the Boredom Away</a>. In this series I will show you how to deploy a particular framework on Clever Cloud every day until I want to go back to boredom. Today it&#39;s about Vert-x and Golo.</p>
<span id="more-2911"></span>

<p>In each post of this series we&#39;ll see how to deploy a particular framework on Clever Cloud. Today we are taking a look at <a href="http://vertx.io/">Vert-x</a> and <a href="http://golo-lang.org/">Golo</a>.</p>
<p>If you want to tag along, make sure you have git, a Clever Cloud account and that you have installed our CLI <a href="https://github.com/CleverCloud/clever-tools">Clever-Tools</a>.</p>
<h2 id="what-is-vert-x">What is Vert-x?</h2>
<p>Eclipse Vert.x is a tool-kit for building reactive applications on the JVM.</p>
<p>And when they write JVM, they mean it. You can use any JVM language. Beyond the polyglot statement, you will find out that it&#39;s also <em>event driven</em> and <em>non blocking</em>. Which means it&#39;s ready to scale and will use your hardware as much as possible. It&#39;s reactive. I invite you to read the <a href="https://www.reactivemanifesto.org/">Reactive Manifesto</a> if you have no idea what it is. Vert-x is unopinionated and as such is a good fit for any kind of application or microservice. Here we will use it to build an API.  </p>
<h2 id="what-is-golo">What is Golo</h2>
<p>A lightweight dynamic language for the JVM.</p>
<p>You can install Golo with a standalone binary available on <a href="http://golo-lang.org/download/">their website</a>. It&#39;s important because today we will also look at how to create a Golo project from scrach instead of using an existing one. All of this is happening thanks to our CSO Philippe Charrière who previously blogged on this subject, check out <a href="https://medium.com/@k33g_org/">his blog</a>!</p>
<h2 id="create-a-golo-project">Create a Golo Project</h2>
<p>In a terminal, type these commands:</p>
<pre><code class="language-bash">golo new vertx.golo.demo --type maven
cd vertx.golo.demo
</code></pre>
<p>The Golo CLI has generated a Golo project:</p>
<pre><code class="language-bash">.
├── pom.xml
├── src
│   └── main
│       └── golo
│           └── main.golo
</code></pre>
<p>To make sure you can compile the project, you have to update the pom.xml file: Change the Golo version by replacing</p>
<pre><code class="language-xml">  &lt;properties&gt;
    &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;golo.version&gt;3.2.0-SNAPSHOT&lt;/golo.version&gt;
  &lt;/properties&gt;
</code></pre>
<p>with:</p>
<pre><code class="language-xml">  &lt;properties&gt;
    &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;golo.version&gt;3.2.0&lt;/golo.version&gt;
    &lt;vertx.version&gt;3.4.1&lt;/vertx.version&gt;
  &lt;/properties&gt;
</code></pre>
<p>Add some dependencies and the bintray repository:</p>
<pre><code class="language-xml">  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.eclipse.golo&lt;/groupId&gt;
      &lt;artifactId&gt;golo&lt;/artifactId&gt;
      &lt;version&gt;${golo.version}&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;com.googlecode.json-simple&lt;/groupId&gt;
      &lt;artifactId&gt;json-simple&lt;/artifactId&gt;
      &lt;version&gt;1.1.1&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;io.vertx&lt;/groupId&gt;
      &lt;artifactId&gt;vertx-core&lt;/artifactId&gt;
      &lt;version&gt;${vertx.version}&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;io.vertx&lt;/groupId&gt;
      &lt;artifactId&gt;vertx-web&lt;/artifactId&gt;
      &lt;version&gt;${vertx.version}&lt;/version&gt;
    &lt;/dependency&gt;

  &lt;/dependencies&gt;

  &lt;repositories&gt;
    &lt;repository&gt;
      &lt;id&gt;bintray&lt;/id&gt;
      &lt;name&gt;Bintray&lt;/name&gt;
      &lt;url&gt;https://jcenter.bintray.com&lt;/url&gt;
    &lt;/repository&gt;
  &lt;/repositories&gt;

  &lt;pluginRepositories&gt;
    &lt;pluginRepository&gt;
      &lt;id&gt;bintray&lt;/id&gt;
      &lt;name&gt;Bintray&lt;/name&gt;
      &lt;url&gt;https://jcenter.bintray.com&lt;/url&gt;
    &lt;/pluginRepository&gt;
  &lt;/pluginRepositories&gt;
</code></pre>
<p>We are going to write a very simple Vert-x web application with Golo. For that, replace the content of <code>/src/main/golo/main.golo</code> with this:</p>
<pre><code class="language-go">module vertx.golo.demo

import io.vertx.core.Vertx
import io.vertx.core.http.HttpServer
import io.vertx.ext.web.Router
import io.vertx.ext.web.handler

import gololang.JSON

let vertx = Vertx.vertx()

function main = |args| {

  let server = vertx: createHttpServer()
  let router = Router.router(vertx)
  router: route(): handler(BodyHandler.create())

  let port =  Integer.parseInt(System.getenv(): get(&quot;PORT&quot;) orIfNull &quot;8080&quot;)

  router: get(&quot;/&quot;): handler(|context| {
    context: response(): putHeader(&quot;content-type&quot;, &quot;text/html;charset=UTF-8&quot;)
    context: response(): end(&quot;&lt;h1&gt;Hello 🌍&lt;/h1&gt;&quot;, &quot;UTF-8&quot;)
  })

  router: get(&quot;/hi&quot;): handler(|context| {
    context: response(): putHeader(&quot;content-type&quot;, &quot;application/json;charset=UTF-8&quot;)
    context: response(): end(JSON.stringify(DynamicObject(): message(&quot;Hi 😛&quot;)), &quot;UTF-8&quot;)
  })

  server: requestHandler(|httpRequest| -&gt; router: accept(httpRequest)): listen(port)

  println(&quot;listening on &quot; + port)
}
</code></pre>
<p>To test the application:</p>
<ul>
<li>Built it with: <code>mvn package</code></li>
<li>Run it with: <code>mvn exec:java</code></li>
<li>Test your web application by opening <code>http://localhost:8080</code> and <code>http://localhost:8080/hi</code></li>
</ul>
<p>If it works locally then you are ready for the next step. Set it up for Clever Cloud.</p>
<h2 id="setup">Setup</h2>
<p>Clever Cloud can run any JVM code packaged as a <em>.war</em> or <em>.jar</em>. You can either checkout those files directly in your Github repository or have them built with Maven or Gradle. In this case it&#39;s a Maven build that generates a <em>.jar</em> file from some Golo code. So when we create the application we have to select maven as type: <code>clever create --type maven vertx-golo-sample</code></p>
<p>The only configurable thing is the port of the server. It defaults to 8080 in the code. It&#39;s also the case for each application running on Clever Cloud as it is required. So nothing to change here, we are ready to deploy.</p>
<h2 id="deploy">Deploy</h2>
<p>To make our Maven buikd work we need to state which build goal is needed and where is the <em>.jar</em> file to run. To do so create in your project directory a <code>clevercloud</code> directory with a <code>jar.json</code> file containing:</p>
<pre><code class="language-json">{
  &quot;build&quot;: {
    &quot;type&quot;: &quot;maven&quot;,
    &quot;goal&quot;: &quot;package&quot;
  },
  &quot;deploy&quot;: {
    &quot;jarName&quot;: &quot;target/vertx.golo.demo-0.0.1-SNAPSHOT-jar-with-dependencies.jar&quot;
  }
}
</code></pre>
<p>It configures your application to run <code>mvn package</code> then <code>java -jar target/vertx.golo.demo-0.0.1-SNAPSHOT-jar-with-dependencies.jar</code>.</p>
<p>The last step to deploy it is to initiate an empty git repository, add and commit your code, then deploy it:</p>
<pre><code class="language-bash">git init
git add src/ pom.xml clevercloud/
git commit -m &quot;first version&quot;
clever deploy
</code></pre>
<p>What <code>clever deploy</code> does is pushing your code to a remote git branch that was created when you created the application in the setup step. Right now you should start seeing build logs in the console. If everything worked well run <code>clever open</code>. It will take you straight to your web application and display Hello 🌍!</p>
]]></description>
										<content:encoded><![CDATA[<p><img width="1400" height="540" src="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" decoding="async" srcset="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1.png 1400w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1-300x116.png 300w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1-1024x395.png 1024w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1-768x296.png 768w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1-1368x528.png 1368w" sizes="(max-width: 1400px) 100vw, 1400px" /></p><p>Welcome to this new edition of <a href="/blog/features/2017/10/09/1fdba-step0/">One Framework a Day keeps the Boredom Away</a>. In this series I will show you how to deploy a particular framework on Clever Cloud every day until I want to go back to boredom. Today it&#39;s about Vert-x and Golo.</p>
<span id="more-2911"></span>

<p>In each post of this series we&#39;ll see how to deploy a particular framework on Clever Cloud. Today we are taking a look at <a href="http://vertx.io/">Vert-x</a> and <a href="http://golo-lang.org/">Golo</a>.</p>
<p>If you want to tag along, make sure you have git, a Clever Cloud account and that you have installed our CLI <a href="https://github.com/CleverCloud/clever-tools">Clever-Tools</a>.</p>
<h2 id="what-is-vert-x">What is Vert-x?</h2>
<p>Eclipse Vert.x is a tool-kit for building reactive applications on the JVM.</p>
<p>And when they write JVM, they mean it. You can use any JVM language. Beyond the polyglot statement, you will find out that it&#39;s also <em>event driven</em> and <em>non blocking</em>. Which means it&#39;s ready to scale and will use your hardware as much as possible. It&#39;s reactive. I invite you to read the <a href="https://www.reactivemanifesto.org/">Reactive Manifesto</a> if you have no idea what it is. Vert-x is unopinionated and as such is a good fit for any kind of application or microservice. Here we will use it to build an API.  </p>
<h2 id="what-is-golo">What is Golo</h2>
<p>A lightweight dynamic language for the JVM.</p>
<p>You can install Golo with a standalone binary available on <a href="http://golo-lang.org/download/">their website</a>. It&#39;s important because today we will also look at how to create a Golo project from scrach instead of using an existing one. All of this is happening thanks to our CSO Philippe Charrière who previously blogged on this subject, check out <a href="https://medium.com/@k33g_org/">his blog</a>!</p>
<h2 id="create-a-golo-project">Create a Golo Project</h2>
<p>In a terminal, type these commands:</p>
<pre><code class="language-bash">golo new vertx.golo.demo --type maven
cd vertx.golo.demo
</code></pre>
<p>The Golo CLI has generated a Golo project:</p>
<pre><code class="language-bash">.
├── pom.xml
├── src
│   └── main
│       └── golo
│           └── main.golo
</code></pre>
<p>To make sure you can compile the project, you have to update the pom.xml file: Change the Golo version by replacing</p>
<pre><code class="language-xml">  &lt;properties&gt;
    &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;golo.version&gt;3.2.0-SNAPSHOT&lt;/golo.version&gt;
  &lt;/properties&gt;
</code></pre>
<p>with:</p>
<pre><code class="language-xml">  &lt;properties&gt;
    &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;golo.version&gt;3.2.0&lt;/golo.version&gt;
    &lt;vertx.version&gt;3.4.1&lt;/vertx.version&gt;
  &lt;/properties&gt;
</code></pre>
<p>Add some dependencies and the bintray repository:</p>
<pre><code class="language-xml">  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.eclipse.golo&lt;/groupId&gt;
      &lt;artifactId&gt;golo&lt;/artifactId&gt;
      &lt;version&gt;${golo.version}&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;com.googlecode.json-simple&lt;/groupId&gt;
      &lt;artifactId&gt;json-simple&lt;/artifactId&gt;
      &lt;version&gt;1.1.1&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;io.vertx&lt;/groupId&gt;
      &lt;artifactId&gt;vertx-core&lt;/artifactId&gt;
      &lt;version&gt;${vertx.version}&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;io.vertx&lt;/groupId&gt;
      &lt;artifactId&gt;vertx-web&lt;/artifactId&gt;
      &lt;version&gt;${vertx.version}&lt;/version&gt;
    &lt;/dependency&gt;

  &lt;/dependencies&gt;

  &lt;repositories&gt;
    &lt;repository&gt;
      &lt;id&gt;bintray&lt;/id&gt;
      &lt;name&gt;Bintray&lt;/name&gt;
      &lt;url&gt;https://jcenter.bintray.com&lt;/url&gt;
    &lt;/repository&gt;
  &lt;/repositories&gt;

  &lt;pluginRepositories&gt;
    &lt;pluginRepository&gt;
      &lt;id&gt;bintray&lt;/id&gt;
      &lt;name&gt;Bintray&lt;/name&gt;
      &lt;url&gt;https://jcenter.bintray.com&lt;/url&gt;
    &lt;/pluginRepository&gt;
  &lt;/pluginRepositories&gt;
</code></pre>
<p>We are going to write a very simple Vert-x web application with Golo. For that, replace the content of <code>/src/main/golo/main.golo</code> with this:</p>
<pre><code class="language-go">module vertx.golo.demo

import io.vertx.core.Vertx
import io.vertx.core.http.HttpServer
import io.vertx.ext.web.Router
import io.vertx.ext.web.handler

import gololang.JSON

let vertx = Vertx.vertx()

function main = |args| {

  let server = vertx: createHttpServer()
  let router = Router.router(vertx)
  router: route(): handler(BodyHandler.create())

  let port =  Integer.parseInt(System.getenv(): get(&quot;PORT&quot;) orIfNull &quot;8080&quot;)

  router: get(&quot;/&quot;): handler(|context| {
    context: response(): putHeader(&quot;content-type&quot;, &quot;text/html;charset=UTF-8&quot;)
    context: response(): end(&quot;&lt;h1&gt;Hello 🌍&lt;/h1&gt;&quot;, &quot;UTF-8&quot;)
  })

  router: get(&quot;/hi&quot;): handler(|context| {
    context: response(): putHeader(&quot;content-type&quot;, &quot;application/json;charset=UTF-8&quot;)
    context: response(): end(JSON.stringify(DynamicObject(): message(&quot;Hi 😛&quot;)), &quot;UTF-8&quot;)
  })

  server: requestHandler(|httpRequest| -&gt; router: accept(httpRequest)): listen(port)

  println(&quot;listening on &quot; + port)
}
</code></pre>
<p>To test the application:</p>
<ul>
<li>Built it with: <code>mvn package</code></li>
<li>Run it with: <code>mvn exec:java</code></li>
<li>Test your web application by opening <code>http://localhost:8080</code> and <code>http://localhost:8080/hi</code></li>
</ul>
<p>If it works locally then you are ready for the next step. Set it up for Clever Cloud.</p>
<h2 id="setup">Setup</h2>
<p>Clever Cloud can run any JVM code packaged as a <em>.war</em> or <em>.jar</em>. You can either checkout those files directly in your Github repository or have them built with Maven or Gradle. In this case it&#39;s a Maven build that generates a <em>.jar</em> file from some Golo code. So when we create the application we have to select maven as type: <code>clever create --type maven vertx-golo-sample</code></p>
<p>The only configurable thing is the port of the server. It defaults to 8080 in the code. It&#39;s also the case for each application running on Clever Cloud as it is required. So nothing to change here, we are ready to deploy.</p>
<h2 id="deploy">Deploy</h2>
<p>To make our Maven buikd work we need to state which build goal is needed and where is the <em>.jar</em> file to run. To do so create in your project directory a <code>clevercloud</code> directory with a <code>jar.json</code> file containing:</p>
<pre><code class="language-json">{
  &quot;build&quot;: {
    &quot;type&quot;: &quot;maven&quot;,
    &quot;goal&quot;: &quot;package&quot;
  },
  &quot;deploy&quot;: {
    &quot;jarName&quot;: &quot;target/vertx.golo.demo-0.0.1-SNAPSHOT-jar-with-dependencies.jar&quot;
  }
}
</code></pre>
<p>It configures your application to run <code>mvn package</code> then <code>java -jar target/vertx.golo.demo-0.0.1-SNAPSHOT-jar-with-dependencies.jar</code>.</p>
<p>The last step to deploy it is to initiate an empty git repository, add and commit your code, then deploy it:</p>
<pre><code class="language-bash">git init
git add src/ pom.xml clevercloud/
git commit -m &quot;first version&quot;
clever deploy
</code></pre>
<p>What <code>clever deploy</code> does is pushing your code to a remote git branch that was created when you created the application in the setup step. Right now you should start seeing build logs in the console. If everything worked well run <code>clever open</code>. It will take you straight to your web application and display Hello 🌍!</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
