As a fan of DDD I sometimes struggle to map the business needs into the current industry standard REST because of its technical nature and entity orientation.
So I went looking for an alternative and found a couple of possible candidates, gRPC+Protobuf, Thrift and Avro.
Of these, it looks like gRPC+Protobuf has the most traction at the moment.
It also has a solid future ahead as it is a strategic choice within Google.
So let’s dive in and find out….
Continue reading →
To get the current Clojure version we must use the clojure-version function. The function simply returns the Clojure version we are using from our code.
In the following example we simply check the result of clojure-version and also define a function to get the Javaa version:
Continue reading →
The keep function in Clojure invokes a function on each item in a collection and only returns non-nil results from the function invocation. The result of the keep function is a lazy sequence.
The following example uses the keep function, but also show what results would be when using map function on the same collection with the same function argument:
Continue reading →
In Clojure we can use the clojure.string/split function to split a string, based on a regular expression, into a vector with string values. Optionally we can also specify a limit on the maximum number of returned string values we want. If we want to split a string based on the newline characters we can use the function clojure.string/split-lines that returns a vector where each element is a line from the original multi-line string.
The following example shows several usages of the split and split-lines functions:
Continue reading →
In my previous blog about Running AWS locally with LocalStack
I’ve shown you how to use Localstack, a tool to mock your AWS environment on your local machine.
When working with Localstack, I always had to prepare the environment for my application to run.
Most of the time this could be done automatically via scripts, but some preparations, for instance editing some data in a S3 bucket, could become a little tricky.
Continue reading →
In Clojure we can use the rand-nth function to get a single random element from a sequence. To get multiple items based on random probability for each item we use the function random-sample. We must set the probability that determines for each item if it is in the result or not.
In the following example code we use rand-nth function:
Continue reading →
We can search for a value in a string and replace it with another value using the clojure.string/replace function. The first parameter is the original string value that we want to replace parts of. The second parameter can be a string value or regular expression. The last parameter is the replacement value that can be a string value or a function that returns a string value. The function itself gets either a string argument if the match has no nested groups (when match is a regular expression) or a vector with a complete match followed by the nested groups when the match has nested groups.
In the following example we several invocation of the clojure.string/replace function with different arguments:
Continue reading →
We can use the flatten function when we have a collection with nested sequential collections as elements and create a new sequence with the elements from all nested collections.
In the following example we use the flatten function:
Continue reading →
In the clojure.set namespace we can find the intersection function. This functions accepts one or more sets as arguments and return a new set with all elements that are present in the sets that are passed as arguments to the intersection function. The argument must be a set, so we need to convert other collection or seq values to a set first before we use it as an argument for the function.
In the following example we use one, two or three arguments for the intersection function and also convert other types to a set to be used as argument:
Continue reading →
We can use the join function from the clojure.string namespace to join elements from a collection into a string. We can optionally specify a separator that is used to separate each element in the string output. The separator is not used after the last element of the collection. If we don’t specify a separator the elements are concatenated without separation. The string representation for each element in the collection is used in the joined end result.
In the following example code we see different usages of the join function:
Continue reading →