Skip to content

Commit 9a4d6d9

Browse files
committed
an overview comment on the Defaults and Env
1 parent dbcf283 commit 9a4d6d9

File tree

1 file changed

+39
-8
lines changed

1 file changed

+39
-8
lines changed

pkg/queue/sharedmain/main.go

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,51 @@ type config struct {
108108
Env
109109
}
110110

111+
// Env exposes parsed QP environment variables for use by Options (QP Extensions)
111112
type Env struct {
112-
ServingNamespace string `split_words:"true" required:"true"`
113-
ServingRevision string `split_words:"true" required:"true"`
113+
// ServingNamespace is the namespace in which the service is defined
114+
ServingNamespace string `split_words:"true" required:"true"`
115+
116+
// ServingService is the name of the service served by this pod
117+
ServingService string `split_words:"true"` // optional
118+
119+
// ServingConfiguration is the name of service configuration served by this pod
114120
ServingConfiguration string `split_words:"true" required:"true"`
115-
ServingPodIP string `split_words:"true" required:"true"`
116-
ServingPod string `split_words:"true" required:"true"`
117-
ServingService string `split_words:"true"` // optional
121+
122+
// ServingRevision is the name of service revision served by this pod
123+
ServingRevision string `split_words:"true" required:"true"`
124+
125+
// ServingPod is the pod name
126+
ServingPod string `split_words:"true" required:"true"`
127+
128+
// ServingPodIP is the pod ip address
129+
ServingPodIP string `split_words:"true" required:"true"`
118130
}
119131

132+
// Defaults provides Options (QP Extensions) with the default bahaviour of QP
133+
// Some attributes of Defaults may be modified by Options
134+
// Modifying Defaults mutates the behavior of QP
120135
type Defaults struct {
121-
Ctx context.Context
122-
Logger *zap.SugaredLogger
136+
// Logger enables Options to use the QP pre-configured logger
137+
// It is expected that Options will use the provided Logger when logging
138+
// Options should not modify the provided Default Logger
139+
Logger *zap.SugaredLogger
140+
141+
// Env exposes parsed QP environment variables for use by Options
142+
// Options should not modify the provided environment parameters
143+
Env Env
144+
145+
// Ctx provides Options with the QP context
146+
// An Option may derive a new context from Ctx. If a new context is derived,
147+
// the derived context should replace the value of Ctx.
148+
// The new Ctx will then be used by other Options (called next) and by QP.
149+
Ctx context.Context
150+
151+
// Transport provides Options with the QP RoundTripper
152+
// An Option may wrap the provided Transport to add a Roundtripper.
153+
// If Transport is wrapped, the new RoundTripper should replace the value of Transport.
154+
// The new Transport will then be used by other Options (called next) and by QP.
123155
Transport http.RoundTripper
124-
Env Env
125156
}
126157

127158
type Option func(*Defaults)

0 commit comments

Comments
 (0)