Our journey towards serverless

Recently we were working on a ticket booking and booking cancelation feature in our Fitradar solution. In our solution the booking process consists of two steps: the place reservation in a sport event and payment. And in case the user for some reason didn’t make a payment the system should execute one more step – cancel the reservation. The process becomes non trivial when each step is done in separate environments – the reservation is done on the back-end, but the payment is done on the client’s device. The most challenging part was to figure out how to cancel the reservation in cases when payment was not made or failed.

So we started to look for possible solutions. Initially we were considering Background tasks with hosted services but we didn’t like the fact that the background task will be in the same process as our main back-end service and we have to make sure the process doesn’t shut down after the request is handled. And since we were using the Azure Cloud for hosting our beck-end services the next thing we started to look at was the WebJob which seemed a very good solution for our use case until we introduced ourselves to the Azure Functions. After some investigation we came to conclusion that Azure Service Bus with message deferral and Azure Functions would be perfect solution. The idea was to send a message to the Service Bus after the user has made a reservation. The Service Bus would deliver the message to our Subscription with 15 minutes delay and our Azure Function would cancel the unpaid booking. In order to receive the scheduled Service Bus message we needed to use Azure Function with Service Bus trigger.

Once we learned more about Azure Functions we decided to use them for other tasks as well that should be done outside the usual request – response pattern. One of such tasks in our solution was User Rating calculation. The task should run on a regular basis every Sunday night. This requirement was perfect job for timer triggered Azure Function.

We started to work on our serverless functions. After the function was scaffolded we started to add our business logic. And since we already had a solid CQRS architecture in place for the main back-end service and for each use case we were creating a separate Command that was using the rest of our infrastructure we wanted to add another Command for reservation cancelation use case, but we faced some .NET Core compatibility issues. Our backend runtime was targeting .NET Core 2.2 version, but our Azure Functions runtime was targeting .NET Core 3.1. Although we could just downgrade our Functions app runtime but the documentation strongly encouraged to use version 3.1, because Function apps that target ~2.0 no longer receives security and other maintenance updates. And so we started to migrate our back-end app to the .NET Core 3.1.

We followed official documentation but still struggled to make our third party libraries work again. The biggest challenge was to find a way how to make to work FluentValidation, MediatR and Swagger together. Once we updated the FluentValidation registration in the Startup file according to the provided documentation it switched off the MediatR Pipeline Behaviors. And once we found a way how to make Pipeline Behaviors work it switched off FluentValidation rules on the Swagger UI page. The Stackoverflow and Google couldn’t help us and we started to experiment with the available settings for FluentValidation and MediatR registration. After several hours of error and trial  we found one setting that made all three libraries work together nice and smooth. Here is the peace of code that made our day:

services.AddMvcCore().AddFluentValidation(fv =>
                {
                    fv.RegisterValidatorsFromAssemblyContaining<PlaceValidator>();
                    fv.RunDefaultMvcValidationAfterFluentValidationExecutes = false;
                    fv.AutomaticValidationEnabled = false;
                });

Now our Fitradar back-end can really benefit from all ASP.NET Core and Azure Functions provided functionality.

P.S. Visit our website: https://www.fitradar.me/ and join the mailing list. Our app is coming soon.

Top 5 reasons to hire a Personal Trainer

1 – Expert Workout Advice – A personal trainer will help you define achievable goals and plan how to meet them. They will create a workout routine specific to your goals and needs while also making allowances for your current physical condition and medical background.

2 – Avoid Injury – Having a trainer demonstrate the correct form, and watch you complete each exercise to ensure you are completing the move in a safe way, will help to avoid any potential injury. Also, your trainer will plan your workouts to maximize the benefits and reduce the possibility of injury or overtraining.

3 – Motivation – Ever feel like you can’t do one more rep or keep going for one more minute? A trainer will push you (safely) to do just one (or two!) more.

4 – Support – Your trainer will be your biggest cheerleader and source of encouragement. I know most trainers became certified for the same reason I did because we want you to succeed in meeting your goals and live a happy and healthy life. A trainer will work with you to overcome any resistance or barriers to creating a healthier life and meeting your health goals.

5 – Focus On You – If you have a unique medical concern, a trainer can work with your physician, physical therapist or other health care provider to plan a safe and efficient program that will speed your recovery or enable you to reach your health goals.

Visit our website: https://www.fitradar.me/ and join the mailing list. Our app is coming soon.

Fitness and mobile app

Hi ! My name is Dmitrijs Beloborodovs

Fitness become one of the buzzwords along with bitcoin or соvid. The first should eventually stop jumping up and down, the second should go away, yet fitness must stay forever. It is crucial to find a good personal trainer to have a smooth start and keep going for a long time. There is something that might help you with that.

Recently I joined a FitRadar team to help with mobile app development. What is a FitRadar (https://fitradar.me) in a nutshell? Briefly: we bring trainers and audience together. Today, your service must be available via different channels: website, integrated in social media and of course, has its own mobile app. A mobile device knows quite much information about you and your habits: your location, language preferences, your schedule and sometimes even specific health metrics (HealthKit is a good example). In other words, it knows enough to propose you a best fitness trainer or sport community in your area, with respect to your timetable, interest or by your friends recommendation. When you start building something great like this, you want to be sure are are building on solid foundation. Here is the first question you might want to evaluate:

Should I go cross platform or native?

Crossplatform solutions (i.e. Flutter, React Native) might look attractive initially, yet brings problems later: super long polishing to achieve smooth and nice UI/UX to mimic platform (all those bounces and responsiveness, etc) and hard path of integration with platform native hardware (location, calendar, etc). So, for us, answer is go 100% native. Stay tuned to know how well we managed to achieve a primary goal of our mobile app — bring nice experience of finding a sport fo your dreams.

Visit our website: https://www.fitradar.me/ and join the mailing list. Our app is coming soon!

P.S. Source: https://medium.com/@dmi3j/fitness-and-mobile-app-3dca370d8e10