Skip to content

Commit

Permalink
renamings
Browse files Browse the repository at this point in the history
  • Loading branch information
jrcamp committed May 19, 2021
1 parent dd2068d commit 2cdfcc4
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 46 deletions.
9 changes: 9 additions & 0 deletions model/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Protocols

This package provides common ways for decoding serialized bytes into protocol-specific in-memory data models (e.g. Zipkin Span). These data models can then be translated to internal pdata representations. Similarly, pdata can be translated from a data model which can then be serialized into bytes.

[serializer](serializer): Common interfaces for serializing/deserializing bytes from/to data models.

[translator](translator): Common interfaces for translating protocol-specific data models from/to pdata.

This package provides higher level APIs that do both encoding of bytes and data model if going directly pdata ⇔ bytes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@

package encoding

// MetricsEncoder encodes data model into bytes.
type MetricsEncoder interface {
EncodeMetrics(model interface{}) ([]byte, error)
// MetricsDeserializer decodes bytes into data model.
type MetricsDeserializer interface {
DeserializeMetrics(bytes []byte) (interface{}, error)
}

// TracesEncoder encodes data model into bytes.
type TracesEncoder interface {
EncodeTraces(model interface{}) ([]byte, error)
// TracesDeserializer decodes bytes into data model.
type TracesDeserializer interface {
DeserializeTraces(bytes []byte) (interface{}, error)
}

// LogsEncoder encodes data model into bytes.
type LogsEncoder interface {
EncodeLogs(model interface{}) ([]byte, error)
// LogsDeserializer decodes bytes into data model.
type LogsDeserializer interface {
DeserializeLogs(bytes []byte) (interface{}, error)
}
18 changes: 9 additions & 9 deletions protocols/encoding/decoder.go → model/serializer/serialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@

package encoding

// MetricsDecoder decodes bytes into data model.
type MetricsDecoder interface {
DecodeMetrics(bytes []byte) (interface{}, error)
// MetricsSerializer encodes data model into bytes.
type MetricsSerializer interface {
SerializeMetrics(model interface{}) ([]byte, error)
}

// TracesDecoder decodes bytes into data model.
type TracesDecoder interface {
DecodeTraces(bytes []byte) (interface{}, error)
// TracesSerializer encodes data model into bytes.
type TracesSerializer interface {
SerializeTraces(model interface{}) ([]byte, error)
}

// LogsDecoder decodes bytes into data model.
type LogsDecoder interface {
DecodeLogs(bytes []byte) (interface{}, error)
// LogsSerializer encodes data model into bytes.
type LogsSerializer interface {
SerializeLogs(model interface{}) ([]byte, error)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,28 @@ package encoding

import "fmt"

// Type is the encoding format that a model is serialized to.
type Type string
// Encoding is the encoding format that a model is serialized to.
type Encoding string

const (
Protobuf Type = "protobuf"
JSON Type = "json"
Thrift Type = "thrift"
Protobuf Encoding = "protobuf"
JSON Encoding = "json"
Thrift Encoding = "thrift"
)

func (e Type) String() string {
func (e Encoding) String() string {
return string(e)
}

// ErrUnavailableEncoding is returned when the requested encoding is not supported.
type ErrUnavailableEncoding struct {
encoding Type
encoding Encoding
}

func (e *ErrUnavailableEncoding) Error() string {
return fmt.Sprintf("unsupported encoding %q", e.encoding)
}

func NewErrUnavailableEncoding(encoding Type) *ErrUnavailableEncoding {
func NewErrUnavailableEncoding(encoding Encoding) *ErrUnavailableEncoding {
return &ErrUnavailableEncoding{encoding: encoding}
}
File renamed without changes.
10 changes: 5 additions & 5 deletions protocols/translation/decoder.go → model/translator/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ type MetricsDecoder interface {
// ToMetrics converts a data model of another protocol into pdata.
ToMetrics(src interface{}) (pdata.Metrics, error)
// Type returns an instance of the model.
Type() interface{}
NewModel() interface{}
}

type TracesDecoder interface {
// ToTraces converts a data model of another protocol into pdata.
ToTraces(src interface{}) (pdata.Traces, error)
// Type returns an instance of the model.
Type() interface{}
// NewModel returns an instance of the model.
NewModel() interface{}
}

type LogsDecoder interface {
// ToLogs converts a data model of another protocol into pdata.
ToLogs(src interface{}) (pdata.Logs, error)
// Type returns an instance of the model.
Type() interface{}
// NewModel returns an instance of the model.
NewModel() interface{}
}
12 changes: 6 additions & 6 deletions protocols/translation/encoder.go → model/translator/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ import "go.opentelemetry.io/collector/consumer/pdata"
type MetricsEncoder interface {
// FromMetrics converts pdata to data model.
FromMetrics(md pdata.Metrics, out interface{}) error
// Type returns an instance of the model.
Type() interface{}
// NewModel returns an instance of the model.
NewModel() interface{}
}

type TracesEncoder interface {
// FromTraces converts pdata to data model.
FromTraces(md pdata.Traces, out interface{}) error
// Type returns an instance of the model.
Type() interface{}
// NewModel returns an instance of the model.
NewModel() interface{}
}

type LogsEncoder interface {
// FromLogs converts pdata to data model.
FromLogs(md pdata.Logs, out interface{}) error
// Type returns an instance of the model.
Type() interface{}
// NewModel returns an instance of the model.
NewModel() interface{}
}
File renamed without changes.
File renamed without changes.
9 changes: 0 additions & 9 deletions protocols/README.md

This file was deleted.

0 comments on commit 2cdfcc4

Please sign in to comment.