Because I didn’t have much practical experience with microservices and I never had the opportunity to do it at the company I currently work for, I thought I do a little experiment that involves the use of microservices and a message bus.

Link to source code

The waiter and the chef are microservices, the customer is just the CLI that talks to the waiter to make an order and then the waiter send the order to chef using the message bus (NSQ), it’s pretty simple and basic really, all it’s does is that it’s send “Pepperoni Pizza” over the bus. But I only needed to prove to myself that I can build microservices, I believe I have succeeded in that, YAY. 😄

What I like about NSQ, compared TCP/IP I don’t have to manually set up a listener and manage the buffer, I can do it but it’s a little bit tedious; so instead I easily set up a Publisher the one that sends the information and the Consumer the one that receives the information.

10/08/2019 17:29 BST

It’s been a little while since I made my last blog post, well I have been a little busy lately with work, working out at the gym, learning to play the guitar, learning a bit of Japanese (trying to master Hiragana ひらがな and Katakana カタカナ is a little bit tricky, hopefully, I get there), playing a couple of video games, mainly Crash Team Racing Nitro-Fueled and Super Mario Maker 2.

I also took the time to learn Rust, I enjoyed it, it’s just the IDE I’m working with is struggling to work with external libraries, so I’m going to stay off Rust until that is fixed, it’s just difficult for me to stay productive without auto-complete, I just can’t keep looking at the document there and back, it’s will burn me out and that no good and I need to work fast. 😄

I'll take time to learn other programming languages, I just don’t want to be that person who uses JavaScript for absolutely everything it’s just unrealistic. If I was developing a video game, I would have used C++, it’s a big language with no garbage collection, I will learn it when I get the time and overcome the fear, but hopefully, it will be fun. I will also take the time to learn Ruby.

If I were to deploy a docker git containers and it’s requires no credential, I could use the following command

$ docker build -t example/image https://github.com/docker/rootfs.git

But what if it does require credentials and I wanted to use ssh public key authentication, the thing is the docker daemon might not have access to the private key used to log into ssh, but there is a solution one could use the git command to create the archive (or tallball) and then pass it to docker, for example.

$ git archive --format tar.gz --output /tmp/example.tar.gz --remote [email protected]:docker/rootfs.git master

$ docker build -t example/image - < /tmp/example.tar.gz

If I wanted to deploy to a remote server, I could make use of scp (to copy) and ssh (to build), for example.

$ git archive --format tar.gz --output /tmp/example.tar.gz --remote [email protected]:docker/rootfs.git master

$ scp /tmp/example.tar.gz [email protected]:/tmp/example.tar.gz

$ ssh [email protected] "docker build -t example/image - < /tmp/example.tar.gz"

Update: This command will not work with podman, you have to extract the tarball.

I don’t need to do port forward or do anything messy, like running ssh in the background, which I have to close when I’m done with it, I just rather not do it that way. Using port forwarding to upload a tarball, honestly, I find that clumsy. I prefer clean simple and elegant solutions to a complex problem.

24/03/2019 19:01 GMT

For dealing with dynamic ip addresses, the most elegant solution I could find, is to place the ip address of the network into a simple file using a shell script and sync the folder across different machine that you trust using file sync software like Syncthing or Relio Sync. Here an example of a script:

#!/bin/bash
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
IP=$(dig -4 +short myip.opendns.com @resolver1.opendns.com)
if [ "$IP" != "$(cat IpAddress/Server)" ]; then
        echo $IP > IpAddress/Server
        # Tips: you could do some fancy curl stuff here, e.g. cloudflare API ;)
fi

And setup a cron to run the script about every 15 minutes.

Yes, one could say you can use DynDNS but there is a few disadvantages to that approach, for example, you can’t control where you’re sourcing the IP address from, you’ll end up distributing the IP address globally which may not be desirable and you’re handing over control to a third party.

How would I use the file with SSH, that easy I show you an example.

$ ssh -o 'HostKeyAlias myhost' [email protected]$(cat ~/IpAddress/Server)

It’s really that simple, just make sure you add the alias to ~/.ssh/known_hosts and you’re done 🙂

10/03/2019 17:13 GMT

I recently swap Mongo DB driver from a third party to the official driver, the process mostly went smoothly because I was well disciplined in writing high quality code and sticking to good practice otherwise it would of took me a lot longer to complete.

I did have a few issues along the way.

| |

Privacy Policy