Skip to content

Instantly share code, notes, and snippets.

@gomaglev
gomaglev / pagination.md
Last active January 27, 2021 08:51
Pagination Best Practice

Pagination

1. Pagination should be ready for all dynamic list responses

Restful API / gRPC shouldn't be designed to meet the output of front-end / third party services. They should be designed as a standard feature to handle any size of data without code modification. Pagination should be considered as a framework level feature.

2. Naming

There two types of naming for pagination.

a. For public

@gomaglev
gomaglev / rest_api.md
Last active January 27, 2021 08:54
Rest API Best Practice

Rest API

REpresentational State Transfer API.

1. REST operations to database operations

POST       - CREATE/INSERT
GET        — SELECT
PUT/PATCH  - UPDATE
@gomaglev
gomaglev / elasticsearch.md
Last active August 13, 2023 13:54
Elasticsearch Best Practice

Elasticsearch

Templates

Elasticsearch is index based storage. Many things need to be considered when creating indices such as properties, data types, number of shards, number of replicas, refresh interval. Elasticsearch doesn't have schemas. All these things can be set when creating the index or use a template to handle it. After template defined, all the indices that match "index_patterns" will apply all the properties in the template. By using templates, it becomes easier to change index settings, mappings and aliases.

@gomaglev
gomaglev / partition.md
Last active January 27, 2021 08:52
Postgres Partitions

Sample function to add monthly partitions

Create partitioned table

CREATE TABLE IF NOT EXISTS order
(
    id varchar(36) NOT NULL,
    created_at     timestamp(3) with time zone NOT NULL,
    updated_at     timestamp(3) with time zone NOT NULL,
@gomaglev
gomaglev / protoc_install.md
Last active March 6, 2024 16:23
Install protoc 3.0 for Go on Mac osx

Download latest version

Protobuf

cd ~
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protoc-3.14.0-osx-x86_64.zip

Unzip file

unzip protoc-3.14.0-osx-x86_64.zip -d protoc3_install