mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-18 19:44:06 -08:00
375ad1185c
* *: bump gRPC dependencies This change updates the gRPC dependencies to more recent versions: * github.com/gogo/protobuf => v1.2.0 * github.com/grpc-ecosystem/grpc-gateway => v1.6.3 * google.golang.org/grpc => v1.17.0 In addition scripts/genproto.sh leverages Go modules information instead of hardcoding SHA1 commits. This ensures that the code is generated from the exact same sources. Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Run 'make proto' in CI Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Revert tabs -> spaces change Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Fix 'make proto' step Signed-off-by: Simon Pasquier <spasquie@redhat.com> * 'go get' grpc/protobuf dependencies Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Prepopulate cache with go mod download Signed-off-by: Simon Pasquier <spasquie@redhat.com>
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package runtime
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io"
|
|
)
|
|
|
|
// JSONBuiltin is a Marshaler which marshals/unmarshals into/from JSON
|
|
// with the standard "encoding/json" package of Golang.
|
|
// Although it is generally faster for simple proto messages than JSONPb,
|
|
// it does not support advanced features of protobuf, e.g. map, oneof, ....
|
|
//
|
|
// The NewEncoder and NewDecoder types return *json.Encoder and
|
|
// *json.Decoder respectively.
|
|
type JSONBuiltin struct{}
|
|
|
|
// ContentType always Returns "application/json".
|
|
func (*JSONBuiltin) ContentType() string {
|
|
return "application/json"
|
|
}
|
|
|
|
// Marshal marshals "v" into JSON
|
|
func (j *JSONBuiltin) Marshal(v interface{}) ([]byte, error) {
|
|
return json.Marshal(v)
|
|
}
|
|
|
|
// Unmarshal unmarshals JSON data into "v".
|
|
func (j *JSONBuiltin) Unmarshal(data []byte, v interface{}) error {
|
|
return json.Unmarshal(data, v)
|
|
}
|
|
|
|
// NewDecoder returns a Decoder which reads JSON stream from "r".
|
|
func (j *JSONBuiltin) NewDecoder(r io.Reader) Decoder {
|
|
return json.NewDecoder(r)
|
|
}
|
|
|
|
// NewEncoder returns an Encoder which writes JSON stream into "w".
|
|
func (j *JSONBuiltin) NewEncoder(w io.Writer) Encoder {
|
|
return json.NewEncoder(w)
|
|
}
|
|
|
|
// Delimiter for newline encoded JSON streams.
|
|
func (j *JSONBuiltin) Delimiter() []byte {
|
|
return []byte("\n")
|
|
}
|