Documentation
¶
Index ¶
Constants ¶
const ( // NonceLength is the length of the string returned by NewNonce. NewNonce encodes the current UNIX // time in nanos and the remaining chunks, encoded as 64-bit and 32-bit integers respectively, then // hex encoded. This means a nonce will always be 8 + 4 bytes, multiplied by 2 by the hex encoding. NonceLength = (8 + 4) * 2 )
Variables ¶
This section is empty.
Functions ¶
func GetTypeURL ¶
func IsPseudoDeltaSotW ¶
IsPseudoDeltaSotW checks whether the given resource type url is intended to behave as a "pseudo delta" resource. Instead of sending the entire state of the world for every resource change, the server is expected to only send the changed resource. From the spec:
In the SotW protocol variants, all resource types except for Listener and Cluster are grouped into responses in the same way as in the incremental protocol variants. However, Listener and Cluster resource types are handled differently: the server must include the complete state of the world, meaning that all resources of the relevant type that are needed by the client must be included, even if they did not change since the last response.
In other words, for everything except Listener and Cluster, the server should only send the changed resources, rather than every resource every time.
func MapToProto ¶
MapToProto serializes the given map using protobuf. It sorts the entries based on the key such that the same map always produces the same output. It then encodes the entries by appending the key then value, and b64 encodes the entire output. Note that the final b64 encoding step is critical as this function is intended to be used with [ads.SotWDiscoveryResponse.Version], which is a string field. In protobuf, string fields must contain valid UTF-8 characters, and b64 encoding ensures that.
func NewNonce ¶
NewNonce creates a new unique nonce based on the current UNIX time in nanos, always returning a string of NonceLength.
func ProtoToMap ¶
ProtoToMap is the inverse of MapToProto. It returns an error on any decoding or deserialization issues.
func TrimTypeURL ¶
TrimTypeURL removes the leading "types.googleapis.com/" prefix from the given string.
Types ¶
type Set ¶
type Set[T comparable] map[T]struct{}
func NewSet ¶
func NewSet[T comparable](elements ...T) Set[T]