Хаки при работе с большим числом мелких файлов

Дело в том, что внутренней спецификой работы наших сервисов является хранение огромадного числа мелких файлов. На данный момент у нас порядка сотен терабайт таких данных. И мы натолкнулись на некоторые очевидные и не очень грабельки и успешно по ним прошлись.Поэтому делюсь нашим опытом, может кому и пригодится. Проблема первая: «No […]

Raw Queries in Laravel

Business logic is often complicated. Because of this, we often need to write our own SQL queries. Luckily, Laravel‘s query builder has the tools we need to safely run such queries. A key concern when writing our own queries is protecting our application from SQL injection attacks. Normally, the query […]

Write string slice line by line to a text file

The bufio package provides an efficient buffered Writer which queues up bytes until a threshold is reached and then finishes the write operation to a file with minimum resources. The following source code snippet shows writing a string slice to a plain text file line-by-line. package main   import ( «bufio» […]

Указатели в Go Lang

Когда мы вызываем функцию с аргументами, аргументы копируются в функцию: func zero(x int) { x = 0 } func main() { x := 5 zero(x) fmt.Println(x) // x всё еще равен 5 } В этой программе функция zero не изменяет оригинальную переменную x из функции main. Но что если мы […]

Правильная регистрация консольных команд Symfony в DI

Как добавить такую команду в DI? <?phpdeclare(strict_types=1);namespace App\Console;use Symfony\Component\Console\Command\Command;final class DoStuffCommand extends Command{ protected function configure(): void { $this ->setName(‘app:do:stuff’) ->setDescription(‘This command does stuff’) ; } // …} Неправильный способ services: _defaults: autoconfigure: true App\Console\DoStuffCommand: ~ # tags: [ console.command ] # с тегом, если не используется автоконфигурация В чем […]

Symfony State Machines and Domain Driven Design

It has been just over 2 years since Symfony released their Workflow component. I was of course thrilled by the news and started to work on multiple PRs to make the component support state machines. It was a really cool experience working with the Symfony community and discussing everything from […]

Работаем с MySQL в Go

Сегодня хочу рассказать о небольшом опыте работы с MySQL (хотя тут можно использовать и любую другую БД) в Go. Я нашел для себя отличный способ работать с БД из Go и спешу им поделиться. Вообще в Go есть несколько важных вещей для того, чтобы делать запросы. Например database/sql и github.com/go-sql-driver/mysql. […]

Pessimistic vs Optimistic Locking in Laravel

Introduction When two or more clients want to update the same record, a conflict may occur which is known as a race condition. To prevent such a conflict, a pessimist system assumes the worst, i.e., the updates always occur at the same time. Thus, it eliminates the race condition by […]

How do slices internally work in golang

Why do slices exists if you already have arrays in golang? Let’s see why we need slices in golang. So in this blog, we will talk about What are slices and why do we need them? How do they internally work in golang? What mistakes can we make while using […]

Database Transactions and Resource Locking in Laravel

Database transactions and pessimistic locking are probably not the most used features, however, they can be extremely useful. Let’s take a brief look and then examine how Laravel’s database layer supports these features. In this post, we don’t focus on the plain SQL implementation of database transactions or locking. After […]