temporalproto

package
v1.33.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2024 License: MIT Imports: 5 Imported by: 11

Documentation

Overview

Deep equality test via reflection on only public methods and members. This is deeply hacky as we're not inside of the reflect package; this will not be as performant as reflect.DeepEqual but will handle proto objects at any point in an object hierarchy

The MIT License

Copyright (c) 2022 Temporal Technologies Inc. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The MIT License

Copyright (c) 2022 Temporal Technologies Inc. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeepEqual

func DeepEqual(x, y any) bool

DeepEqual behaves as reflect.DeepEqual except: 1. Proto structs will be compared using proto.Equal when encountered 2. Only public member variables will be compared

DeepEqual should _only_ be used when proto.Equal or reflect.DeepEqual aren't useable, such as when comparing normal Go structs that have proto structs as members

Types

type CustomJSONMarshalOptions

type CustomJSONMarshalOptions struct {
	// Metadata is used for storing request metadata, such as whether shorthand
	// payloads are disabled
	Metadata map[string]interface{}

	// Indent specifies the set of indentation characters to use in a multiline
	// formatted output such that every entry is preceded by Indent and
	// terminated by a newline. If non-empty, then Multiline is treated as true.
	// Indent can only be composed of space or tab characters.
	Indent string
}

CustomJSONMarshalOptions is a configurable JSON format marshaler that supports both TYPE_PREFIXED_SCREAMING_SNAKE enums as well as camelCase enums.

func (CustomJSONMarshalOptions) Marshal

func (o CustomJSONMarshalOptions) Marshal(m proto.Message) ([]byte, error)

Marshal marshals the given proto.Message in the JSON format using options in MarshalOptions. Do not depend on the output being stable. It may change over time across different versions of the program.

type CustomJSONUnmarshalOptions

type CustomJSONUnmarshalOptions struct {
	// Metadata is used for storing request metadata, such as whether shorthand
	// payloads are disabled
	Metadata map[string]interface{}

	// If DiscardUnknown is set, unknown fields and enum name values are ignored.
	DiscardUnknown bool
}

CustomJSONUnmarshalOptions is a configurable JSON format marshaler that supports both TYPE_PREFIXED_SCREAMING_SNAKE enums as well as camelCase enums.

func (CustomJSONUnmarshalOptions) Unmarshal

func (o CustomJSONUnmarshalOptions) Unmarshal(b []byte, m proto.Message) error

Unmarshal reads the given []byte and populates the given proto.Message using options in the UnmarshalOptions object. It will clear the message first before setting the fields. If it returns an error, the given message may be partially set. The provided message must be mutable (e.g., a non-nil pointer to a message). This is different from the official protojson unmarshaling code in that it supports unmarshaling our shorthand payload format as well as both camelCase and SCREAMING_SNAKE_CASE JSON enums

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL