-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasegroup.zzzgo
216 lines (188 loc) · 4.5 KB
/
basegroup.zzzgo
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
package xop
import (
"sync"
"time"
"github.com/xoplog/xop-go/trace"
"github.com/xoplog/xop-go/xopat"
"github.com/xoplog/xop-go/xopbase"
"github.com/xoplog/xop-go/xopnum"
)
type baseLoggers []xopbase.Logger
type baseRequests struct {
baseSpans
baseRequests []xopbase.Request
}
type baseSpans []xopbase.Span
type lines []xopbase.Line
type prefilleds []xopbase.Prefilled
type prefillings []xopbase.Prefilling
var _ xopbase.Request = baseRequests{}
var _ xopbase.Span = baseSpans{}
var _ xopbase.Line = lines{}
var _ xopbase.Prefilled = prefilleds{}
var _ xopbase.Prefilling = prefillings{}
func (l baseLoggers) StartRequests(ctx context.Context, ts time.Time, span trace.Bundle, descriptionOrName string) (xopbase.Request, map[string]xopbase.Request) {
if len(l) == 1 {
req := l[0].Request(ctx, ts, span, descriptionOrName)
return req, map[string]xopbase.Request{l[0].ID(): req}
}
m := make(map[string]xopbase.Request)
r := baseRequests{
baseSpans: make(baseSpans, 0, len(l)),
baseRequests: make([]xopbase.Request, 0, len(l)),
}
for _, logger := range l {
id := logger.ID()
if _, ok := m[id]; ok {
// duplicate!
continue
}
req := logger.Request(ctx, ts, span, descriptionOrName)
r.baseRequests = append(r.baseRequests, req)
r.baseSpans = append(r.baseSpans, req.(xopbase.Span))
m[id] = req
}
return r, m
}
func (l baseLoggers) ReferencesKept() bool {
for _, logger := range l {
if logger.ReferencesKept() {
return true
}
}
return false
}
func (l baseLoggers) Buffered() bool {
for _, logger := range l {
if logger.Buffered() {
return true
}
}
return false
}
func (s baseRequests) SetErrorReporter(f func(error)) {
for _, request := range s.baseRequests {
request.SetErrorReporter(f)
}
}
func (s baseRequests) Final() {
for _, request := range s.baseRequests {
go func() {
request.Final()
}()
}
}
func (s baseRequests) Flush() {
var wg sync.WaitGroup
wg.Add(len(s.baseRequests))
for _, request := range s.baseRequests {
go func() {
defer wg.Done()
request.Flush()
}()
}
wg.Wait()
}
func (s baseSpans) Span(ctx context.Context, t time.Time, span trace.Bundle, descriptionOrName string, spanSequenceCode string) xopbase.Span {
baseSpans := make(baseSpans, len(s))
for i, ele := range s {
baseSpans[i] = ele.Span(ctx, t, span, descriptionOrName, spanSequenceCode)
}
return baseSpans
}
func (s baseSpans) Done(t time.Time, final bool) {
for _, span := range s {
span.Done(t, final)
}
}
func (s baseSpans) ID() string {
panic("this is not expected to be called")
}
func (s baseSpans) Boring(b bool) {
for _, span := range s {
span.Boring(b)
}
}
func (s baseSpans) NoPrefill() xopbase.Prefilled {
prefilled := make(prefilleds, len(s))
for i, span := range s {
prefilled[i] = span.NoPrefill()
}
return prefilled
}
func (s baseSpans) StartPrefill() xopbase.Prefilling {
prefilling := make(prefillings, len(s))
for i, span := range s {
prefilling[i] = span.StartPrefill()
}
return prefilling
}
func (p prefillings) PrefillComplete(m string) xopbase.Prefilled {
prefilled := make(prefilleds, len(p))
for i, prefilling := range p {
prefilled[i] = prefilling.PrefillComplete(m)
}
return prefilled
}
func (p prefilleds) Line(level xopnum.Level, t time.Time, pc []uintptr) xopbase.Line {
lines := make(lines, len(p))
for i, prefilled := range p {
lines[i] = prefilled.Line(level, t, pc)
}
return lines
}
func (l lines) Template(m string) {
for _, line := range l {
line.Template(m)
}
}
func (l lines) Msg(m string) {
for _, line := range l {
line.Msg(m)
}
}
func (l lines) Static(m string) {
for _, line := range l {
line.Static(m)
}
}
func (l lines) Enum(k *xopat.EnumAttribute, v xopat.Enum) {
for _, line := range l {
line.Enum(k, v)
}
}
func (p prefillings) Enum(k *xopat.EnumAttribute, v xopat.Enum) {
for _, prefilling := range p {
prefilling.Enum(k, v)
}
}
// MACRO BaseDataWithoutType
func (p prefillings) ZZZ(k string, v zzz) {
for _, prefilling := range p {
prefilling.ZZZ(k, v)
}
}
// MACRO BaseDataWithType
func (p prefillings) ZZZ(k string, v zzz, dt xopbase.DataType) {
for _, prefilling := range p {
prefilling.ZZZ(k, v, dt)
}
}
// MACRO BaseDataWithoutType
func (l lines) ZZZ(k string, v zzz) {
for _, line := range l {
line.ZZZ(k, v)
}
}
// MACRO BaseDataWithType
func (l lines) ZZZ(k string, v zzz, dt xopbase.DataType) {
for _, line := range l {
line.ZZZ(k, v, dt)
}
}
//MACRO BaseAttribute
func (s baseSpans) MetadataZZZ(k *xopat.ZZZAttribute, v zzz) {
for _, span := range s {
span.MetadataZZZ(k, v)
}
}