Fork me on GitHub
#beginners
<
2018-11-15
>
Mario C.01:11:29

Hopefully this question is in the right channel but what is WildFly? From their site > WildFly is a flexible, lightweight, managed application runtime that helps you build amazing applications. Which I am not entirely sure what that is. Do I need it to run my Clojure application?

hiredman01:11:50

wildfly is an app server which is sort of like a framework

Mario C.01:11:15

So Wildfly, Jetty, Undertow, TomCat, Apache, Nginx all more or less do the same thing?

Mario C.01:11:51

A person writes a API in Clojure that then becomes a Java application which runs on the JVM which runs along side (Wildfly, Jetty, Undertow...) which runs on a machine?

noisesmith01:11:20

the Wildfly server runs clojure.main to run your code, more likely

hiredman01:11:34

I wouldn't get too hung up on the taxonomy of the whatever

Mario C.01:11:33

I like to be able to see the connection of these things

hiredman01:11:38

the problem is a lot of those words you used there are overloaded

hiredman01:11:16

app servers are basically generic applications running on top of the jvm

hiredman01:11:23

they don't run a long side it

hiredman01:11:49

they provide a kind of standard environment for your application to run in

hiredman01:11:00

I haven't seen app servers themselves used a lot with clojure, but older clojure code bases often end up looking kind of like an app server

hiredman01:11:33

a lot of app servers come with a webserver as part of the environment, and sometimes you can use that webserver without the appserver as well (jetty, undertow)

hiredman01:11:47

I think undertow might actually be the webserver wildfly uses

seancorfield01:11:28

I think the most common way to run Clojure web applications is with the embedded Jetty server (followed by http-kit and Aleph perhaps?)... Since the Jetty adapter has been bundled with Ring for a long time. I gather Immutant is now available as an embedded server library for Ring as well...

Dormo01:11:11

Immutant will work just fine without an application server.

Dormo01:11:52

Not just the HTTP server, but the caching, scheduling, and transactions libraries as well.

seancorfield01:11:33

Yeah, it was only the 1.x version of Immutant that required a JBoss app server in order to run. I remember trying the library version a while back http://immutant.org/documentation/2.1.10/apidoc/guide-web.html

Mario C.01:11:10

Got it. Its just starts getting difficult to understand when I see terms like web server/app server used interchangeably. Then seeing that an app is deployed to Wildfly using JBoss and i start to get scambled

seancorfield01:11:28

(Immutant uses Undertow?)

Dormo01:11:52

Undertow, Infinispan, HornetQ, and something else for transactions

Mario C.01:11:04

immutant.web.undertow

seancorfield01:11:12

@mario.cordova.862 In the Java world, you'll hear folks talk about Servlet containers, app servers, web servers... but in the Clojure world we can ignore most of that.

seancorfield01:11:42

You can create a WAR file for container-based deployment but you don't need to.

Dormo01:11:03

As someone who was wondering exactly what Mario was wondering very recently, I wish there was some guide on what benefits an application server provides

Dormo01:11:17

All Immutant docs say is that you can use it with Wildfly if you want

Dormo01:11:22

Doesn't go into the why

Dormo01:11:41

literally what you just linked.

noisesmith01:11:42

I think people use eg. Docker with java inside to get most of the benefits

noisesmith01:11:12

monitoring, automatic restarts or recovery of some sort, log aggregation, etc.

noisesmith01:11:39

with Docker it's the same tooling / setup you used with Ruby or whatever (a common case)

Dormo01:11:54

You can also run Wildfly inside docker :thinking_face:

Dormo01:11:10

not sure if there's a practical reason to do so...

noisesmith01:11:21

right - but if you didn't have Docker or Wildfly, you would have to do some goofy things to ensure your process was running, check logs, etc.

hansw14:11:49

In java-land, in the past 5 years, people have also been embedding an 'appserver' into their application instead of deploying their app to some container. See Spring Boot.

hansw14:11:09

Clojure apps also embed a webserver. This is to say, there isn't much difference here.

Audrius14:11:58

What are options for Streaming of text. I don't want to slurp everything into memory at once. is there any way for streaming in Clojure?

manutter5114:11:09

Sure, check out line-seq

mewa15:11:30

Is there any obvious way to one incorporate version string into clojurescript build artifacts? (leiningen & cljsbuild)

mfikes15:11:11

@marcin.k.chmiel One way is to use :closure-defines

mewa15:11:10

@mfikes thanks. I was unclear, what I meant was to produce files named like when generating jars (i.e. artifact-$projectVersion.js)

mfikes15:11:29

@marcin.k.chmiel There is a new feature that will put a fingerprint in the filename (not a version, but a hash)

mewa16:11:09

How about a more generic way, like running code inside project.clj?

mewa16:11:46

Ok, got it. I knew it was possible, but forgot everything inside defproject is quoted. I defined version before and unquotted it in compiler options

(def version "0.1.0-SNAPSHOT")
(def output (str "resources/public/js/main-" version ".js"))
...
:compiler {:optimizations :advanced
                                   :output-to ~output
                                   }

hansw16:11:59

Hmm. Is there some clojury-thing I'm missing here... I'm surprised https://github.com/weavejester/ragtime exists

hansw16:11:08

So what I'm asking is: does ragtime offer something that flyway can't, simply because it was written in Clojure?

hoopes17:11:12

Hi, I'm trying to add a set of default styles on (for example) a material-ui button. In the code below, I'd like styles to be applied to the button - but I'm not sure where/when/how to apply it.

(ns ui.buttons.basic
  (:require [reagent.core :as r]
            [stylefy.core :as s]
            ["@material-ui/core/Button" :default Button]))

(def styles {:background-color "red"})
(def button (r/adapt-react-class Button))
I want to be able to (require [ui.buttons.basic :as b]) and use the button with the red background. Am I missing something obvious? I'm using shadow-cljs to have access to material-ui like that...Thanks!

adam22:11:01

Hello everyone. I am wondering if I should place [hiccup "1.0.5"] under {:dev {:dependencies or :dependencies [

noisesmith22:11:04

when is hiccup used?

seancorfield22:11:22

@somedude314 It depends on how you're using Hiccup -- as part of your dev workflow only, or as part of your intended (production) runtime?

adam22:11:04

I am using it with Compojure to display HTML

adam22:11:26

Not sure what that qualifies it for

noisesmith22:11:53

if anything in your running app uses hiccup, don't put it under :dev

seancorfield22:11:31

The :dev profile is intended for development-time tooling, not "normal" runtime.

adam22:11:14

Aha, got it. I thought it won't be needed after the compilation to uberjar. Thanks.

noisesmith22:11:22

the question is whether any code path compiles hiccup data to html - doing that as a build step would be valid, but not how most people do things

Will22:11:41

I have a java project with some clojure code that is called from java. For testing I use an in memory h2 database. What is the correct way to test my clojure methods that call a database? My clojure code currently creates a connection pool to whatever database(s) I need to connect to on startup, and I am not sure how to test the methods? How do I connect to the h2 db? How do I setup the code so that it builds the connection pool when running in production but can connect to the h2 db when running tests?

schmee22:11:00

for connecting to the DB you can use https://github.com/clojure/java.jdbc

schmee22:11:19

for choosing different DBs in test and prod you most likely want to use something like Component or Mount

hiredman22:11:45

if you are parameterizing code over some value (for example different database connections), the best way to do that is to have functions that take that value as a parameter