
Microservices Communication in .NET Using gRPC
By :

So far, we have only used examples of strongly typed Protobuf definitions, which means that, if we have set the data type of any particular field, it cannot just dynamically change to a different data type. Yes, some data types are compatible with each other. For example, you can send an int32
value to an int64
field. But what you can't do is send a string
value where int64
is expected.
But there might be cases where you will need the ability to change the data type of a variable depending on the situation. For example, this could be relevant when your system is expected to interoperate with loosely typed programming languages, such as JavaScript or PHP, or schema-less messaging formats, such as JSON.
Even C# has this capability, despite being a strongly typed language. In C#, there is a data type called dynamic
. It can change to any data type depending on requirements.
Luckily, this is possible with gRPC too. There are...