IT Nights — ночная конференция в Иннополисе

Приглашаю всех на ИТ конференцию в г.Иннополис 🙂

АНОНС МЕРОПРИЯТИЯ:

1–3 АВГУСТА 
ИННОПОЛИС, РЕСПУБЛИКА ТАТАРСТАН

IT Nights – Первая ночная конференция 
для ИТ-специалистов. 
Потому что ночью происходит 
всё самое интересное. 

https://it-nights.ru

ПОДРОБНЕЕ О ГОРОДЕ:

Иннопо́лис — город в Верхнеуслонском районе Республики Татарстан, город-спутник Казани, входящий в её агломерацию. В поселении расположены Университет Иннополис и особая экономическая зона «Иннополис». 

http://www.innopolis.com

GopherCon 2019

Побывали на Российской ГоферКонфе 🙂

Было очень полезно и интересно, очень понравились доклады от Konrad Reiche(go generate: One File to Rule Them All) и Денис Исаев(Линтеры в Go: как их готовить).

http://gophercon-russia.ru

Golang Hints: Create MongoDB Object ID from String

Sometimes you may want to find something by the Object ID in your MongoDB and due to you URI or query string contains ID you should convert the string ID to Object ID.

Below is a code that converts string ID to Object ID:

 package main

import (
"go.mongodb.org/mongo-driver/bson/primitive"
"fmt"
)
func main() {
oid, err := primitive.ObjectIDFromHex(recordID)

fmt.Printf("%s %v", err, oid)

  // if err := collection.FindOne(ctx, bson.M{"_id": oid}).Decode(e); err != nil {
  // return nil, err
// }
}

Presenting Go-Up

Today I have started development of new package for Golang-developers – Go-Up. I made it because I have noticed that I should repeat some things with each new project on Golang, so the main purpose of Go-Up package is to simplify building of new Golang applications.

This is a beginning so I just want to share link to GitHub here – https://github.com/ildarusmanov/go-up

KrakenD config example

What is KrakenD?

KrakenD is your self-designed REST API Gateway that feeds from your existing data services (Your APIs, legacy, cloud, IoT…) Just define visually or in a configuration file the endpoints your applications will use and the KrakenD will fetch and transform the content at your will for you.

https://www.krakend.io

Configuration example(proxy for POST, GET requests):

{
  "version": 2,
  "extra_config": {
    "github_com/devopsfaith/krakend-gologging": {
      "level": "WARNING",
      "prefix": "[KRAKEND]",
      "syslog": false,
      "stdout": true
    },
    "github_com/devopsfaith/krakend-metrics": {
      "collection_time": "60s",
      "proxy_disabled": false,
      "router_disabled": false,
      "backend_disabled": false,
      "endpoint_disabled": false,
      "listen_address": ":8090"
    },
    "github_com/devopsfaith/krakend-cors": {
      "allow_origins": [ "*" ],
      "allow_methods": [ "POST", "GET", "PUT", "DELETE" ],
      "allow_headers": [
        "Origin",
        "Authorization",
        "Content-Type",
        "Accept",
        "X-Auth-Token"
      ],
      "expose_headers": [ "Content-Length" ],
      "max_age": "12h"
    }
  },
  "timeout": "3000ms",
  "cache_ttl": "300s",
  "output_encoding": "no-op",
  "name": "api-proxy",
  "port": 80,
  "endpoints": [
    {
      "endpoint": "/",
      "extra_config": {},
      "output_encoding": "no-op",
      "concurrent_calls": 1,
      "backend": [
        {
          "url_pattern": "/",
          "encoding": "no-op",
          "extra_config": {},
          "sd": "static",
          "host": [
            "http://some-landing"
          ],
          "disable_host_sanitize": false
        }
      ]
    },
    {
      "method": "GET",
      "endpoint": "/api/v1/endpoint}",
      "extra_config": {},
      "output_encoding": "no-op",
      "concurrent_calls": 1,
      "backend": [
        {
          "method": "POST",
          "url_pattern": "/api/v1/{endpoint}",
          "encoding": "no-op",
          "extra_config": {},
          "sd": "static",
          "host": [
            "http://backend-service-getter"
          ],
          "disable_host_sanitize": false
        }
      ]
    },
    {
      "method": "POST",
      "endpoint": "/api/v1/endpoint}",
      "extra_config": {},
      "output_encoding": "no-op",
      "concurrent_calls": 1,
      "backend": [
        {
          "method": "POST",
          "url_pattern": "/api/v1/{endpoint}",
          "encoding": "no-op",
          "extra_config": {},
          "sd": "static",
          "host": [
            "http://backend-service-poster"
          ],
          "disable_host_sanitize": false
        }
      ]
    },
}

[Щепотка мудрости] Качество решений не определяет результат

«Качество решений не определяет результат, — отметил Канеман в выступлении. — Можно принять очень хорошее решение и получить плохой результат, потому что не повезло. А можно принять плохое решение и получить хороший результат, если повезет».

Источник: vc.ru

Golang 1.11.2: dep ensure failed

Problem:


$ dep ensure
panic: version queue is empty, should not happen
goroutine 1 [running]:
github.com/golang/dep/gps.(*solver).findValidVersion(0xc00021e000, 0xc00026ac80, 0xc0001e6440, 0x1, 0x1, 0x0, 0xc0001e6440)
/home/travis/gopath/src/github.com/golang/dep/gps/solver.go:915 +0x4ec
github.com/golang/dep/gps.(*solver).createVersionQueue(0xc00021e000, 0xc0003ab0c1, 0x14, 0x0, 0x0, 0xc0001e6440, 0x1, 0x1, 0x0, 0x0, ...)
/home/travis/gopath/src/github.com/golang/dep/gps/solver.go:902 +0x46e
github.com/golang/dep/gps.(*solver).solve(0xc00021e000, 0xa64e60, 0xc0000a8188, 0x7c72ab, 0x936c80, 0xc00003c060)
/home/travis/gopath/src/github.com/golang/dep/gps/solver.go:505 +0x611
github.com/golang/dep/gps.(*solver).Solve(0xc00021e000, 0xa64e60, 0xc0000a8188, 0xdfa9c8, 0xc00002c0dc, 0x1f, 0xc00019b5c0)
/home/travis/gopath/src/github.com/golang/dep/gps/solver.go:440 +0xc0
main.(*ensureCommand).runUpdate(0xc000185960, 0xc0000c6980, 0xc00019a860, 0x0, 0x0, 0xc0000f6090, 0xa68f00, 0xc0000afc80, 0xc00002c0c4, 0x37, ...)
/home/travis/gopath/src/github.com/golang/dep/cmd/dep/ensure.go:356 +0x1c0
main.(*ensureCommand).Run(0xc000185960, 0xc0000c6980, 0xc00019a860, 0x0, 0x0, 0x0, 0x0)
/home/travis/gopath/src/github.com/golang/dep/cmd/dep/ensure.go:216 +0x7d4
main.(*Config).Run(0xc0000af0e0, 0x0)
/home/travis/gopath/src/github.com/golang/dep/cmd/dep/main.go:212 +0x1070
main.main()
/home/travis/gopath/src/github.com/golang/dep/cmd/dep/main.go:84 +0x53d
The command "dep ensure -update" failed and exited with 2 during .

Solution:

Add to your Gopkg.toml this lines:


[[override]]
name = "gopkg.in/fsnotify.v1"
source = "gopkg.in/fsnotify/fsnotify.v1"

And try to start dep ensure again.

Рабочий пример Kafka в docker / docker-compose

version: '3.4'
services:
zookeeper:
image: confluentinc/cp-zookeeper:latest
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
kafka:
image: confluentinc/cp-kafka:latest
depends_on:
- zookeeper
ports:
- 9092:9092
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1