Skip to content

Commit c473438

Browse files
committed
Revert "Replace interface{} with any"
1 parent a06ffd2 commit c473438

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+136
-137
lines changed

analyzer/analyzer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func New() *analysis.Analyzer {
2424
return a
2525
}
2626

27-
func run(pass *analysis.Pass) (any, error) {
27+
func run(pass *analysis.Pass) (interface{}, error) {
2828
inspector := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
2929

3030
// Expect workflows to be top level functions in a file. Therefore it should be enough to just keep track if the current
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package workflow
22

3-
type Context any
3+
type Context interface{}

backend/converter/converter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import (
66

77
type Converter interface {
88
// To converts the given value to a payload
9-
To(v any) (payload.Payload, error)
9+
To(v interface{}) (payload.Payload, error)
1010

1111
// From converts the given payload to a value
12-
From(data payload.Payload, v any) error
12+
From(data payload.Payload, v interface{}) error
1313
}
1414

1515
var DefaultConverter Converter = &jsonConverter{}

backend/converter/json.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import (
88

99
type jsonConverter struct{}
1010

11-
func (jc *jsonConverter) To(v any) (payload.Payload, error) {
11+
func (jc *jsonConverter) To(v interface{}) (payload.Payload, error) {
1212
return json.Marshal(v)
1313
}
1414

15-
func (jc *jsonConverter) From(data payload.Payload, vptr any) error {
15+
func (jc *jsonConverter) From(data payload.Payload, vptr interface{}) error {
1616
return json.Unmarshal(data, vptr)
1717
}

backend/history/history.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ type Event struct {
131131
ScheduleEventID int64 `json:"seid,omitempty"`
132132

133133
// Attributes are event type specific attributes
134-
Attributes any `json:"attr,omitempty"`
134+
Attributes interface{} `json:"attr,omitempty"`
135135

136136
VisibleAt *time.Time `json:"vat,omitempty"`
137137
}
@@ -154,7 +154,7 @@ func VisibleAt(visibleAt time.Time) HistoryEventOption {
154154
}
155155
}
156156

157-
func NewHistoryEvent(sequenceID int64, timestamp time.Time, eventType EventType, attributes any, opts ...HistoryEventOption) *Event {
157+
func NewHistoryEvent(sequenceID int64, timestamp time.Time, eventType EventType, attributes interface{}, opts ...HistoryEventOption) *Event {
158158
e := &Event{
159159
ID: uuid.NewString(),
160160
SequenceID: sequenceID,
@@ -170,7 +170,7 @@ func NewHistoryEvent(sequenceID int64, timestamp time.Time, eventType EventType,
170170
return e
171171
}
172172

173-
func NewPendingEvent(timestamp time.Time, eventType EventType, attributes any, opts ...HistoryEventOption) *Event {
173+
func NewPendingEvent(timestamp time.Time, eventType EventType, attributes interface{}, opts ...HistoryEventOption) *Event {
174174
return NewHistoryEvent(0, timestamp, eventType, attributes, opts...)
175175
}
176176

backend/history/serialization.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ func (e *Event) UnmarshalJSON(data []byte) error {
2828
return nil
2929
}
3030

31-
func SerializeAttributes(attributes any) ([]byte, error) {
31+
func SerializeAttributes(attributes interface{}) ([]byte, error) {
3232
return json.Marshal(attributes)
3333
}
3434

35-
func DeserializeAttributes(eventType EventType, attributes []byte) (attr any, err error) {
35+
func DeserializeAttributes(eventType EventType, attributes []byte) (attr interface{}, err error) {
3636
switch eventType {
3737
case EventType_WorkflowExecutionStarted:
3838
attr = &ExecutionStartedAttributes{}

backend/mock_Backend.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/mysql/events.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ func insertEvents(ctx context.Context, tx *sql.Tx, tableName string, instance *c
2828
batchEvents := events[batchStart:batchEnd]
2929

3030
aquery := "INSERT IGNORE INTO `attributes` (event_id, instance_id, execution_id, data) VALUES (?, ?, ?, ?)" + strings.Repeat(", (?, ?, ?, ?)", len(batchEvents)-1)
31-
aargs := make([]any, 0, len(batchEvents)*4)
31+
aargs := make([]interface{}, 0, len(batchEvents)*4)
3232

3333
query := "INSERT INTO `" + tableName +
3434
"` (event_id, sequence_id, instance_id, execution_id, event_type, timestamp, schedule_event_id, visible_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)" +
3535
strings.Repeat(", (?, ?, ?, ?, ?, ?, ?, ?)", len(batchEvents)-1)
3636

37-
args := make([]any, 0, len(batchEvents)*8)
37+
args := make([]interface{}, 0, len(batchEvents)*8)
3838

3939
for _, newEvent := range batchEvents {
4040
a, err := history.SerializeAttributes(newEvent.Attributes)

backend/mysql/mysql.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ func (b *mysqlBackend) RemoveWorkflowInstances(ctx context.Context, options ...b
239239

240240
placeholders := strings.Repeat(",?", len(instanceIDs)-1)
241241
whereCondition := fmt.Sprintf("instance_id IN (?%v) AND execution_id IN (?%v)", placeholders, placeholders)
242-
args := make([]any, 0, len(instanceIDs)*2)
242+
args := make([]interface{}, 0, len(instanceIDs)*2)
243243
for i := range instanceIDs {
244244
args = append(args, instanceIDs[i])
245245
}
@@ -670,7 +670,7 @@ func (b *mysqlBackend) CompleteWorkflowTask(
670670

671671
// Remove handled events from task
672672
if len(executedEvents) > 0 {
673-
args := make([]any, 0, len(executedEvents)+1)
673+
args := make([]interface{}, 0, len(executedEvents)+1)
674674
args = append(args, instance.InstanceID, instance.ExecutionID)
675675
for _, e := range executedEvents {
676676
args = append(args, e.ID)
@@ -817,7 +817,7 @@ func (b *mysqlBackend) GetActivityTask(ctx context.Context, queues []workflow.Qu
817817

818818
now := time.Now()
819819

820-
args := make([]any, 0, len(queues)+1)
820+
args := make([]interface{}, 0, len(queues)+1)
821821
args = append(args, now)
822822
for _, q := range queues {
823823
args = append(args, string(q))

backend/redis/events.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type eventWithoutAttributes struct {
1717
func (e *eventWithoutAttributes) MarshalJSON() ([]byte, error) {
1818
return json.Marshal(&struct {
1919
*history.Event
20-
Attributes any `json:"attr"`
20+
Attributes interface{} `json:"attr"`
2121
}{
2222
Event: e.Event,
2323
Attributes: nil,
@@ -44,7 +44,7 @@ var addPayloadsCmd = redis.NewScript(`
4444
`)
4545

4646
func (rb *redisBackend) addEventPayloadsP(ctx context.Context, p redis.Pipeliner, instance *core.WorkflowInstance, events []*history.Event) error {
47-
args := make([]any, 0)
47+
args := make([]interface{}, 0)
4848

4949
for _, event := range events {
5050
payload, err := json.Marshal(event.Attributes)
@@ -67,7 +67,7 @@ func addEventToStreamP(ctx context.Context, p redis.Pipeliner, streamKey string,
6767
return p.XAdd(ctx, &redis.XAddArgs{
6868
Stream: streamKey,
6969
ID: "*",
70-
Values: map[string]any{
70+
Values: map[string]interface{}{
7171
"event": string(eventData),
7272
},
7373
}).Err()

0 commit comments

Comments
 (0)