Skip to content

Instantly share code, notes, and snippets.

View r3code's full-sized avatar

Dmitriy S. Sinyavskiy r3code

View GitHub Profile
@r3code
r3code / last-error-with-stack.go
Created April 12, 2021 15:03
Get last error with stack
// import gihub.com/pkg/errors
// Stack returns the last error in the error chain implementing StackTrace() or nil iа no errors with stack trace
func Stack(err error) errors.StackTrace {
type (
causer interface {
Cause() error
}
stackTracer interface {
StackTrace() errors.StackTrace
}
@r3code
r3code / protobuf-guidelines.md
Created April 2, 2021 12:17
Protobuf Guidelines

Используем protobuff версии 3 https://developers.google.com/protocol-buffers/docs/proto3

Придерживаемся стиля https://developers.google.com/protocol-buffers/docs/style

Если вы удалили поля message определенные ранее, то для сохранения совместимости, их номера должны быть помечены как reserved, чтобы их нельзя было использовать повторно после.

Поддержка версионирования API - см. https://google.aip.dev/215

Переиспользуем готовые определения часто используемых типов (время, деньги, дата и др.) см. https://google.aip.dev/213

@r3code
r3code / kubectl-exec-command.md
Last active April 2, 2021 10:27
Execute command in Kubernetis Pod
ENV_NAME=some_branch
POD_NAME=`kubectl get pods -n $ENV_NAME | grep pod_name_part- | head -n 1 | awk '{print $1}'`; print $POD_NAME

kubectl exec -n $ENV_NAME $POD_NAME -- /app/appctl arg1 arg2

<scheme name="Material Palenight (r3code)" version="142" parent_scheme="Darcula">
<option name="FONT_SCALE" value="1.0" />
<metaInfo>
<property name="created">2021-03-27T17:27:10</property>
<property name="ide">GoLand</property>
<property name="ideVersion">2020.3.4.0.0</property>
<property name="modified">2021-03-27T17:27:46</property>
<property name="originalScheme">Material Palenight (r3code)</property>
</metaInfo>
<option name="LINE_SPACING" value="1.1" />
@r3code
r3code / microservices-error-propagation.md
Last active March 27, 2021 09:43
Передача ошибок между микросервисами

Передача ошибок между микросервисами

В вызывающем сервисе ошибки от запрашиваемого сервиса должны оборачиваться в местные подходящие ошибки (https://softwareengineering.stackexchange.com/questions/351047/upstreaming-microservices-errors)

Предлагаю использовать https://tools.ietf.org/html/rfc7807

{
Status: 400|500|401|403
Path: /api/v1/merchants

Errors: [

@r3code
r3code / golang-learning-readmap.md
Last active April 16, 2021 15:18
Что учить по GoLang?
@r3code
r3code / golang-code-introspection.md
Created March 27, 2021 09:33
Интроспекция Go кода
@r3code
r3code / structured-logging.md
Last active March 24, 2021 12:15
Structured logging best practices

Structured logging best practices (from NLog fo java)

  • The message logged should be the same every time. It should be a constant string, not a string formatted to contain data values such as ids or quantities. Then it is easy to search for.
  • The message logged should be distinct i.e. not the same as the message produced by an unrelated log statement. Then searching for it does not match unrelated things as well.
  • The message should be a reasonable length i.e. longer than a word, but shorter than an essay.
  • The data should be simple values. Use field values of types e.g. string, int, decimal, DateTimeOffset, or enum types. StructuredLogging.Json does not log hierarchical data, just a flat list of key-value pairs. The values are serialised to string with some simple rules: Nulls are serialised as empty strings. DateTime values (and DateTime?, DateTimeOffset and DateTimeOffset?) are serialised to string in ISO8601 date and time format. Everything else is just serialised with .ToStr
@r3code
r3code / resume.json
Last active December 4, 2022 18:48
Dmitriy S. Sinyavskiy Resume / CV (created with https://gitconnected.com/r3code/resume)
{
"basics": {
"name": "Dmitriy S. Sinyavskiy",
"label": "Go Developer | Site Reliability Engineer",
"image": "https://avatars0.githubusercontent.com/u/1355056?v=4",
"url": "https://habr.com/ru/users/r3code/",
"summary": "I'm a software developer with more than 17 years of experience. I try to do my best and encourage teammates to do the same. \n\nI prefer to create documented, well organized and tested code. Other developer should have an ability to start working with the code without any need to ask me about it.\n\nMy open-source code here at GitHub: https://github.com/r3code\n\nOther hobbies:\n* teach kids computer science and programming\n* ship-modeling from plastic\n* snowboarding\n\nI like to work with people. I can understand what stakeholder really need and translate the data to the developers language. Before tell, I listen then propose. For me, it is very important to do the work! I use Kanban board to manage task flow and EventStorming methodology to und
@r3code
r3code / db.go
Created November 4, 2020 17:40 — forked from adamfdl/db.go
package sql
import (
"database/sql"
)
var (
ErrNoRows = sql.ErrNoRows
)