Conf42 Golang 2024 - Online

Revolutionize Go Microservices with GoFr: Build Efficient, Scalable, and Observable Applications

Video size:


Upgrade your development journey with GoFr by seamless integration with multiple databases, pub/sub models, it empowers developers to build efficient, performant, and observable applications with ease. Say goodbye to complexity and hello to robust observability features.


  • Gopher is an opinionated web framework written in Go. It was built with the aim to extract the process of building robust and scalable applications. We will show you how you can build a sample API using Gopher with MySQL as a database.
  • Gopher allows developers to not worry about the other has such as managing a database connection or implementing tracing. This leads to less time production, easy to debug code and it increases the developer productivity. Do visit our repo on GitHub and give it a star if you like it.


This transcript was autogenerated. To make changes, submit a PR.
Hello everyone. In this session we will be talking about Gopher opinionated Go framework for accelerated microservice development. Our todays agenda will be to start with an intro to Gopher. Later we will move forward to its features. After that, I will show you how you can build a sample API using Gopher with MySQL as a database. Later we will conclude on what we have discussed. Gopher is an opinionated web framework written in Go. It was built with the aim to extract the process of building robust and scalable applications and is designed to offer a user friendly experience for all the developers. It helps in building robust and scalable applications. The framework is designed such that it powers you to focus on the main features rather than worrying about a lot of minor things which we will discuss now with Google. Developers can bid fable to tedious setup tasks and focus on what truly matters building exceptional services GoPro streamlines this journey by offering a feature rich framework that empowers you to exploit development and build production ready solutions. Here is a brief list of features Gopher offers to its developers. Out of the box observability gopher shifts with built in observability as soon as you build your application. It provides detailed traces and matrices. Say goodbye to guesswork. Your system is production ready from the get. It also allows you to create your custom traces and custom metrics as per your need. Authentication GoPro has inbuilt support for OAuth, basic auth and API key based authentication and systems. You need not to worry about that, you can just use the feature which is already present in proof, fine tune logging and on the fly. Log level management our framework offers granular log level at different levels which are worn in four notice debug pattern. You can tailor your log to different environments, ensuring clarity and efficiency. It also provides you to change the log level on the go without restarting your applications or changing the deployment support for both rest and GRPC based APIs. It provides you with inbuilt configuration management where you can set the configurations and use them in the application. Go for supports MySQL, redis and popular pubsub systems like Kafka, Google Cloud and MQtt. And guess what? We are actively adding more database support. Your data layer your choices when making an endless service call. Woofer provides you with an option to add a circuit breaker to your application which makes sure that you don't hit the same service again and again if it is not responding back. This is an open source project which is built by developers for developers making production ready applications. Let's dive into code to see how you can use code. Let's start creating our sample project. We are in the new directory sample API. Let's initialize our project. We have done our basic setup. Let's get go for using Go get. This is the basic setup we need to write a gopher application. These two lines, go for new and app dot run are the most basic lines which will be present in every gopher application. Go for new is called. It initializes the framework and handles various steps including initial id using logos, metrics, data sources, etcetera. Based on the context provided when app run is called, it configures, initializes, and runs the HTTP server and serves middlewares. It manages essential features such as routes for health check, endpoints, metrics, server etcetera. By default, it starts the server on the port 8000, which we can override using the configs. Let's try to register a route for our project. When we register our route, it takes two things, the route itself and a handler function. Handler function takes the context and returns interface and l. Let's return hello world from here. Let's take the dependencies and run our project. Our server runs on port 8000 and we see proper logs coming in forever stuff which go for let's hit the green endpoint and we see the well formatted output of hello world on our screen with a proper status code 200 which go for is setting it for us based on the rest API guidelines. Gopher formats every output in the data struct to keep it consistent among different multiple microservices. Gopher also formats the logs for every request. It generates a new request coordination id and with a proper status code in the log at the time taken by the let's connect our application to a database. Gopher supports connecting to SQL databases as well as redis based on configuration variables. Let's get the configuration from over documentation to connect to MySQL, let's run the MySQL instance in a docker container. Let's get the configurations to connect to the database. These configurations are in sync with the docker command if you run it. Configurations are present in the config directory in env file. Let's run our application. Our application is connected to the MySQL database test DB just a few configs and Google let us automatically connect to a database and users can conveniently access DB methods from the context itself. Let's try to run a database command now read handle club c dot equal dot value. Let's run show databases scan. We can see that the application ran successfully and we were able to get a response information schema from the database. Go first. Suppose MySQL postgres was SQL databases. It also supports Redis and Mongo which can be used directly without much code. For changing from MySQL to postgres, user needs to update the configuration and just need to change the DB data from MySQL to postgres. Gopher also pushes let's change the log level from configs to debug. We see that the debug logs are now coming in. Let's run the again so we see that the query row is coming again with the very which we actually ran. This helps in performance training the application and we get all the logs by default using by changing the document exposure to tracing. Woofer provides this user with this set of features to track down their applications performance. Monitor any bugs making it production ready let's start with metrics. When we run our application, Gopher by default starts the metrics on port 2121 which is evident from the logs. Let's see what all metrics are being used. Gopher by default pushes some metrics related to the application function which are the number of both teams SQL in use connections, SQL pen connections. When we send a request, offer by default adds those metrics like apps equals bucket like how much time the request to the SB response bucket, how much time they want. Apart from the path which was at the status return, users can also add their custom metrics from the context with the method metrics. It allows you to create a new metric as well as increment the older metrics which were already created. Go for sports four types of metrics counter upgrade, counter histogram and watch. Users can also change the default metric port 2121 from the configs by adding the config matrix. Now the metric server is running on port 1900. Offer also utilizes the open elementary standard for tracing, providing detailed information about each user request. This helps you understand how requests flow through your application and identify potential issues. Let's set up tracing for our application. Let's save on our documentation to see the traces we need to install zipkin in our system. I already have it running, so it is. Let's add the context here. Tracer post which is 2005 in my case and praise exporter which is zip code. So now we got the one that sporting precise. You see the let's get the quotation id of the request. When we search the request, we got the flow of the request application we had the green endpoint, it went to the router and later it came to the handle. Let's see go observability in action I have known the Gopher repo and using the examples present there. I've used the public dashboards available for Gopher on and set it up in my local system. Grafana is an open source data visualization and monitoring solution. With Grafana you can easily correct, correlate and visualize the data using informative dashboard. I am running HTTP server from Gopher. Examples have generated a load to replicate the production load. Here you can see how our application is performing as well as we can see the number of requests received, time it took and the status quo returned, along with the number of outbound SQL queries which ran and the Redis commands which were executed in the dashboard. Innovation let's see how distributed tracing works in Gopher. I have set up two different applications, one of which is using redis as well, and we can see the places here where we can see how the request is flowing from our first application sample API to using HTTP service and it is coming back to the sample API where it is being processed further. Gopher allows developers to not worry about the other has such as managing a database connection or implementing tracing and allow them to focus more more on what really matters, the core functionality which leads to less time production, easy to debug code and it increases the developer productivity. Thank you everyone. This was it from my side. Hope it was informative. Do visit our repo on GitHub and give it a star if you like it.

Aryan Mehrotra

Software Developer @

Aryan Mehrotra's LinkedIn account Aryan Mehrotra's twitter account

Awesome tech events for

Priority access to all content

Video hallway track

Community chat

Exclusive promotions and giveaways