This repository has been archived by the owner on Sep 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
storage_factory.go
66 lines (54 loc) · 1.9 KB
/
storage_factory.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"flag"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/jaegertracing/jaeger/plugin"
"github.com/jaegertracing/jaeger/storage"
"github.com/jaegertracing/jaeger/storage/dependencystore"
"github.com/jaegertracing/jaeger/storage/spanstore"
"github.com/spf13/viper"
"github.com/uber/jaeger-lib/metrics"
"go.uber.org/zap"
)
type DynamoDBStorageFactory struct {
svc *dynamodb.DynamoDB
metricsFactory metrics.Factory
logger *zap.Logger
tableName string
}
func (d *DynamoDBStorageFactory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger) error {
d.metricsFactory = metricsFactory
d.logger = logger
sess, err := session.NewSession()
if err != nil {
return err
}
d.svc = dynamodb.New(sess)
return nil
}
// CreateSpanReader creates a spanstore.Reader.
func (d *DynamoDBStorageFactory) CreateSpanReader() (spanstore.Reader, error) {
d.logger.Info("Creating SpanReader for DynamoDB with table=" + d.tableName)
return nil, nil
}
// CreateSpanWriter creates a spanstore.Writer.
func (d *DynamoDBStorageFactory) CreateSpanWriter() (spanstore.Writer, error) {
d.logger.Info("Creating SpanWrtier for DynamoDB with table=" + d.tableName)
return nil, nil
}
// CreateDependencyReader creates a dependencystore.Reader.
func (d *DynamoDBStorageFactory) CreateDependencyReader() (dependencystore.Reader, error) {
d.logger.Info("Creating DependencyReader for DynamoDB with table=" + d.tableName)
return nil, nil
}
func (d *DynamoDBStorageFactory) AddFlags(flagSet *flag.FlagSet) {
flagSet.Int("dynamodb.table-name", 30, "DynamoDB Table Name")
}
func (d *DynamoDBStorageFactory) InitFromViper(v *viper.Viper) {
d.tableName = v.GetString("dynamodb.table-name")
}
var factory = DynamoDBStorageFactory{}
// Export the needed symbols
var Configurable plugin.Configurable = &factory
var StorageFactory storage.Factory = &factory;