forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexporter_type.go
45 lines (37 loc) · 834 Bytes
/
exporter_type.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package trace
import (
"errors"
"fmt"
"strings"
)
const (
GRPC ExporterType = iota + 1
HTTP
)
var errUnknownExporterType = errors.New("unknown exporter type")
func ExporterTypeFromString(exporterTypeStr string) (ExporterType, error) {
switch strings.ToLower(exporterTypeStr) {
case GRPC.String():
return GRPC, nil
case HTTP.String():
return HTTP, nil
default:
return 0, fmt.Errorf("%w: %q", errUnknownExporterType, exporterTypeStr)
}
}
type ExporterType byte
func (t ExporterType) MarshalJSON() ([]byte, error) {
return []byte(`"` + t.String() + `"`), nil
}
func (t ExporterType) String() string {
switch t {
case GRPC:
return "grpc"
case HTTP:
return "http"
default:
return "unknown"
}
}