Why do errors not return in the Process method? Need to fix and send fully working code.
Golang
What is the difference between relational databases and NoSQL?
Why are you entering the market now?
What are channels in Go and the select operator?
How does binary search work in a sorted list?
Besides B-tree, what other structures are used for indexes in databases?
What direction or project have you been assigned to in your current organization?
Can you use context to pass data between components or functions?
What is a pointer and how much does it weigh?
What is a race condition and what are ways to protect against it?
Documents are received by the service message Document { string Url = 1; // Document URL, its unique identifier uint64 PubDate = 2; // Document publication time uint64 FetchTime = 3; // Time of receiving this document update, can be considered as version ID. Pair (Url, FetchTime) is unique. string Text = 4; // Document text uint64 FirstFetchTime = 5; // Initially absent, needs to be filled } Documents can arrive in any order (not in the order they were updated), and duplicates of individual messages are also possible. It is necessary to form the same messages at the output, but with corrected individual fields according to the following rules (for a group of documents with the same Url field): Text and FetchTime fields should be the latest received at the moment (the one with the highest FetchTime) PubDate should be the one from the message with the smallest FetchTime FirstFetchTime should be the minimum FetchTime value In other words, at each moment, we take PubDate and FirstFetchTime from the earliest version (sorted by FetchTime), and Text from the latest. The interface in code can be implemented as follows: type Processor interface { Process(doc *Document) (*Document, error) } This code will work in a service reading input messages from a message queue (Kafka or similar), and writing the result back to the queue. If Process returns Null - nothing is written to the queue.
What is the difference between a goroutine and an operating system thread?
What is the difference between a process and a thread?
What are probes in Kubernetes, how to configure them, and what types are there?
How to use select to work with multiple channels simultaneously?
What else besides mutex can be used to protect against race conditions?
What is a channel in Go and what are its main areas of application?
/ * Given a string containing characters (){}. Determine whether the input string is balanced in terms of brackets. * / func isBalanced(s string) bool { // TODO: implement this return false } fmt.Println(isBalanced("()")) // -> true fmt.Println(isBalanced("({()})")) // -> true fmt.Println(isBalanced("(()")) // -> false fmt.Println(isBalanced("(()))")) // -> false fmt.Println(isBalanced("({})")) // -> false
What is iteration over a string using for range in Go? What are the variables i and v inside the loop, and what are their data types?
What is virtual memory (swap), when is it needed, and when should it be disabled?