|
@ -20,6 +20,7 @@ type Event struct { |
|
|
Args []string |
|
|
Args []string |
|
|
Text string |
|
|
Text string |
|
|
Tags map[string]string |
|
|
Tags map[string]string |
|
|
|
|
|
RenderTags map[string]string |
|
|
|
|
|
|
|
|
ctx context.Context |
|
|
ctx context.Context |
|
|
cancel context.CancelFunc |
|
|
cancel context.CancelFunc |
|
@ -28,8 +29,6 @@ type Event struct { |
|
|
|
|
|
|
|
|
targets []Target |
|
|
targets []Target |
|
|
targetIds map[Target]string |
|
|
targetIds map[Target]string |
|
|
|
|
|
|
|
|
RenderTags map[string]string |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// NewEvent makes a new event with Kind, Verb, Time set and Args and Tags initialized.
|
|
|
// NewEvent makes a new event with Kind, Verb, Time set and Args and Tags initialized.
|
|
@ -200,6 +199,30 @@ func (event *Event) MarshalJSON() ([]byte, error) { |
|
|
return json.Marshal(data) |
|
|
return json.Marshal(data) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (event *Event) Copy() *Event { |
|
|
|
|
|
eventCopy := *event |
|
|
|
|
|
if len(event.Args) > 0 { |
|
|
|
|
|
eventCopy.Args = append(event.Args[:0:0], event.Args...) |
|
|
|
|
|
} |
|
|
|
|
|
if len(event.Tags) > 0 { |
|
|
|
|
|
eventCopy.Tags = make(map[string]string, len(event.Tags)) |
|
|
|
|
|
for key, value := range event.Tags { |
|
|
|
|
|
eventCopy.Tags[key] = value |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if len(event.RenderTags) > 0 { |
|
|
|
|
|
eventCopy.RenderTags = make(map[string]string, len(event.RenderTags)) |
|
|
|
|
|
for key, value := range event.RenderTags { |
|
|
|
|
|
eventCopy.RenderTags[key] = value |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if len(event.targets) > 0 { |
|
|
|
|
|
eventCopy.targets = append(event.targets[:0:0], event.targets...) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return &eventCopy |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
type eventJSONData struct { |
|
|
type eventJSONData struct { |
|
|
Name string `json:"name"` |
|
|
Name string `json:"name"` |
|
|
Kind string `json:"kind"` |
|
|
Kind string `json:"kind"` |
|
|