@@ -10,6 +10,7 @@ import (
10
10
"go.temporal.io/server/common/metrics"
11
11
p "go.temporal.io/server/common/persistence"
12
12
commongocql "go.temporal.io/server/common/persistence/nosql/nosqlplugin/cassandra/gocql"
13
+ "go.temporal.io/server/common/persistence/serialization"
13
14
"go.temporal.io/server/common/resolver"
14
15
)
15
16
21
22
clusterName string
22
23
logger log.Logger
23
24
session commongocql.Session
25
+ serializer serialization.Serializer
24
26
}
25
27
)
26
28
@@ -46,6 +48,28 @@ func NewFactory(
46
48
return NewFactoryFromSession (cfg , clusterName , logger , session )
47
49
}
48
50
51
+ // NewFactoryWithSerializer returns an instance of a factory object with a custom serializer
52
+ func NewFactoryWithSerializer (
53
+ cfg config.Cassandra ,
54
+ r resolver.ServiceResolver ,
55
+ clusterName string ,
56
+ logger log.Logger ,
57
+ metricsHandler metrics.Handler ,
58
+ serializer serialization.Serializer ,
59
+ ) * Factory {
60
+ session , err := commongocql .NewSession (
61
+ func () (* gocql.ClusterConfig , error ) {
62
+ return commongocql .NewCassandraCluster (cfg , r )
63
+ },
64
+ logger ,
65
+ metricsHandler ,
66
+ )
67
+ if err != nil {
68
+ logger .Fatal ("unable to initialize cassandra session" , tag .Error (err ))
69
+ }
70
+ return NewFactoryFromSessionWithSerializer (cfg , clusterName , logger , session , serializer )
71
+ }
72
+
49
73
// NewFactoryFromSession returns an instance of a factory object from the given session.
50
74
func NewFactoryFromSession (
51
75
cfg config.Cassandra ,
@@ -58,6 +82,24 @@ func NewFactoryFromSession(
58
82
clusterName : clusterName ,
59
83
logger : logger ,
60
84
session : session ,
85
+ serializer : serialization .NewSerializerWithEncoding (serialization .EncodingTypeFromEnv ()),
86
+ }
87
+ }
88
+
89
+ // NewFactoryFromSessionWithSerializer returns an instance of a factory object from the given session with a custom serializer.
90
+ func NewFactoryFromSessionWithSerializer (
91
+ cfg config.Cassandra ,
92
+ clusterName string ,
93
+ logger log.Logger ,
94
+ session commongocql.Session ,
95
+ serializer serialization.Serializer ,
96
+ ) * Factory {
97
+ return & Factory {
98
+ cfg : cfg ,
99
+ clusterName : clusterName ,
100
+ logger : logger ,
101
+ session : session ,
102
+ serializer : serializer ,
61
103
}
62
104
}
63
105
@@ -88,7 +130,7 @@ func (f *Factory) NewClusterMetadataStore() (p.ClusterMetadataStore, error) {
88
130
89
131
// NewExecutionStore returns a new ExecutionStore.
90
132
func (f * Factory ) NewExecutionStore () (p.ExecutionStore , error ) {
91
- return NewExecutionStore (f .session ), nil
133
+ return NewExecutionStore (f .session , f . serializer ), nil
92
134
}
93
135
94
136
// NewQueue returns a new queue backed by cassandra
0 commit comments