Go Works: Episode 3 - Omnipotent Team

The 21st century killer picture being placed at the modern art exhibition’s wall can be described as the art masterpiece that is beautiful to death on one artist’s hand and is super cheap on the other one. In other words the application that possesses simple for understanding code base, uses the minimum amount of resources and realizes all of the requested by the customer or market requirements. Golang - is the perfect instrument for painting any networks projects and the main tool being used by the Ordnance Networks team of artists.

The data exchange is one of the most challenging, always demanding attention, and met during the Ordnance Networks project’s development picture’s process. The one artist may state that TCP and UDP providing the transport mechanism simultaneously simply and fully solves the client and server need to exchange the information, but the messages are sent across the network as a sequence of bytes, which has no structure except a linear stream of bytes. An application typically includes complex data structures to hold the current program state. In conversing with a remote client or service, the program will be attempting to transfer such data structures across the network - thereby outside of the application’s own address space. That is when Golang built-in Gob package comes in handy with the 2 “by’s” on the way by being go-centric. It is understandable by other go artists and efficient by using a binary encoding mentioned the one higher to transfer the data using the remote procedure call pattern (GRPC, Go RPC).

Gob is a serialization pattern specific to Go programming language, which is designed to encode and decode specifically Go data types. It does support mostly all Go data types: integers of all types and sizes, strings and booleans, structs, arrays, and slices. Gob encodes data type into its serialized forms, that is included once for each piece of data, but takes, for example, the names of struct fields. The following inclusion of data type makes Gob encoding and decoding fairly robust to changes or differences between the marshaller and unmarshaller.

For example, this struct:

                                        
                                        struct T {
                                            a int
                                            b int
                                        }
                                        
                                    

Can be marshalled and then unmarshalled into a different struct, where the order of fields has changed:

                                        
                                        struct T {
                                            b int
                                            a int
                                        }
                                        
                                    

Nowadays most standalone applications are not intended to use message passing techniques a lot such as socket and http programming because of the amount of resources it takes. Generally the desired solving the stated higher problem mechanism is to create and part the specific function, method or procedure call meaning a program will call a function with a list of parameters and on completion of the method call, will have a set of return values which may be the function value, or if addresses have been passed as parameters then the contents of those addresses might have been switched. The remote procedure call is an attempt to bring this style of programming into the network world, thereby a client will make it as a normal procedure call. The client side will package this into a network message and transfer it to the server which will decode and turn it back into a procedure call on the server side. This way tons of messages will be transported efficiently and fastly between the client and server cutting the picture’s expenses.

The painting marathon approaching its end does not take Software God and young disciple adieu, but it gives Agilites and Ordnance Networks a resplendent meal with the future charming software engineering aftertaste.

Written by: Konstantin Yevchuk, Golang Software Engineer


Related Posts


Share it: