Golang: testing http and grpc servers

HTTP server is quite easy to test — here is a nice video about it:

Count lines in git repository

git ls-files | xargs wc -l https://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository

Algorithms to find fastest route through network

This is a great article on that — https://www.redblobgames.com/pathfinding/a-star/introduction.html (in russain). It tells about Dijkstra, Breadth-first, Greedy and A* algorithms. It’s all about optimization of one travel. To optimize your entire network you should try to use Aint Colony algorithm — http://rain.ifmo.ru/cat/data/theory/unsorted/ant-algo-2006/article.pdf (it’s in russian). Another link to this PDF file — aca

How go code is being compiled to assembler code

https://go.godbolt.org/z/31FyJ3 I was interested in comparing line 15 vs line 17 of the following code: package main import «fmt» type kv struct { key []byte value []byte } type sliceMap []kv func (sm *sliceMap) Add(k, v []byte) { kvs := *sm if cap(kvs) > len(kvs) { kvs = kvs[:len(kvs)+1] } else { kvs = append(kvs, …

Read more

E2E tests in go

I tried it via ginkgo and gomega. It has Agouti with WebDriver support out of the box, but I didn’t use it as we have grpc API. That’s the example (table tests): var _ = Describe(«GetRoute», func() { var ( srClient sr.Client srErr error ) JustBeforeEach(func() { srClient, srErr = GetClient() }) DescribeTable(«positive cases», func(fromGeoPointID, …

Read more

What is teamlead’s first duty

Sarah Mei «We think awful code is written by awful devs. But in reality, it’s written by reasonable devs in awful circumstances.» (source) So, teamlead is there to improve circumstances.

ORM for go

https://github.com/Masterminds/squirrel Never used it as we always write SQL queries manually. But looks okay for ORM (well, actually a query-builder).

Kubernetes’ cronjobs

That’s what it is — https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/ Get all cronjobs in env: kubectl —kubeconfig … —namespace platform -o wide get cronjobs Get info on exact cronjob: kubectl —kubeconfig … —namespace platform describe cronjob/smartrouting-cron-import-from-bi Get pods with this cronjob: kubectl —kubeconfig … —namespace platform -o wide get pods|grep «rou» Get logs of cronjob kubectl —kubeconfig … —namespace …

Read more

Crontab time format

That’s about it: min hour day/month month day/week Execution time 30 0 1 1,6,12 * — 00:30 Hrs  on 1st of Jan, June & Dec. 0 20 * 10 1-5 –8.00 PM every weekday (Mon-Fri) only in Oct. 0 0 1,10,15 * * — midnight on 1st ,10th & 15th of month 5,10 0 10 …

Read more

How to make grpc call from shell

1 https://github.com/grpc/grpc/blob/master/doc/command_line_tool.md grpc_cli call localhost:7020 ChatAPI.GetChats «external_user:{id:’30594028′,type:1}, limit:10, offset:0, order:ORDER_DESC, requested_by_external_user:{id:’30594028′,type:1},with_unread_count:true» 2 https://github.com/fullstorydev/grpcurl grpcurl -plaintext -emit-defaults -d ‘{«lozon_id»: 15515160432000}’ -H ‘User-Name: grpcurl’ localhost:7020 points/FindPointByLozonID