Sobes.tech

Tell me more about the Avito project — was it the only project for three years?

Senior
226

func (c *Client) Send(ctx context.Context, messages []Message, maxWorkers int) error { sem := make(chan struct{}, maxWorkers) var wg sync.WaitGroup var resultErr error var once sync.Once for _, msg := range messages { wg.Add(1) go func(msg Message) { defer wg.Done() sem <- struct{}{} defer func() { <-sem }() body, err := json.Marshal(msg) if err != nil { once.Do(func() { resultErr = err; cancel() }) return } req, _ := http.NewRequestWithContext( ctx, http.MethodPost, c.url, bytes.NewReader(body), ) req.Header.Set("Content-Type", "application/json") resp, err := c.httpClient.Do(req) if err != nil { once.Do(func() { resultErr = err; cancel()}) return } defer resp.Body.Close() if resp.StatusCode >= 500 { once.Do(func() { resultErr = fmt.Errorf("server error") cancel()}) return } c.sentCount.Add(1) time.Sleep(time.Second) }(msg) } wg.Wait() }

Senior
220

What is the type of msg in a goroutine and why should it be passed as an argument?

Senior
211

/* The developer was tasked with writing a notification sending service. Requirements: - The Send method should send messages in parallel. - No more than maxworkers HTTP requests can be executed simultaneously. - If at least one send fails, stop the rest and return an error. - The method should handle context cancellation properly. - All resources should be released correctly. - The method can be called concurrently from different goroutines. - The Client should keep track of the number of successfully sent messages. Review the code, find issues, and fix it.

Senior
194

Where should you defer resp.Body.Close()?

Senior
191

Are there any agreements with other employers or are you still in interview stages?

Senior
190

Why is resultErr not returned directly from the goroutine?

Senior
188

Tell us about AllTools — why did you join and why did you leave?

Senior
177

What is your overall commercial experience in Go development?

Senior
177

Will it be comfortable to work with technical documentation in English?

Senior
177

What experience do you have with SQL? Can you write and optimize queries?

Senior
171

Where do contexts end in this code?

Senior
170

What are quick games?

Senior
162

sentCount is transmitted without synchronization — how to fix this?

Senior
157

What happens if you do not pass a context in a database query?

Senior
154

What are you looking for in a new project? What technologies interest you? What would you not want to see at a new workplace?

Senior
152

When will an index not help or even harm?

Senior
132

What stages are usually present in a CI/CD pipeline for a Go service?

Senior
129
Questions for Golang preparation - sobes.tech