MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / initGateway

Method initGateway

module/log/iml.go:197–250  ·  view source on GitHub ↗
(ctx context.Context, clusterId string, clientDriver gateway.IClientDriver)

Source from the content-addressed store, hash-verified

195}
196
197func (i *imlLogModule) initGateway(ctx context.Context, clusterId string, clientDriver gateway.IClientDriver) error {
198 drivers := log_driver.Drivers()
199 if len(drivers) < 1 {
200 return nil
201 }
202
203 for _, driver := range drivers {
204 factory, has := log_driver.GetFactory(driver)
205 if !has {
206 log_print.Errorf("driver %s not found", driver)
207 continue
208 }
209 info, err := i.service.GetLogSource(ctx, driver)
210 if err != nil {
211 log_print.Errorf("get log source %s error: %s", driver, err)
212 continue
213 }
214 d, c, err := factory.Create(info.Config)
215 if err != nil {
216 log_print.Errorf("create driver %s error: %s,config: %s", driver, err, info.Config)
217 continue
218 }
219 log_driver.SetDriver(driver, d)
220 dynamicClient, err := clientDriver.Dynamic(driver)
221 if err != nil {
222 log_print.Errorf("get dynamic client %s error: %s", driver, err)
223 continue
224 }
225 attr := make(map[string]interface{})
226 attr["driver"] = driver
227 attr["formatter"] = logFormatter
228 attr["labels"] = labels
229 attr["method"] = "POST"
230 for k, v := range c {
231 attr[k] = v
232 }
233 err = dynamicClient.Online(ctx, &gateway.DynamicRelease{
234 BasicItem: &gateway.BasicItem{
235 ID: driver,
236 Description: "collect access log",
237 Version: time.Now().Format("20060102150405"),
238 Resource: gateway.ProfessionOutput,
239 },
240 Attr: attr,
241 })
242 if err != nil {
243 log_print.Errorf("online driver %s error: %s", driver, err)
244 continue
245 }
246
247 }
248
249 return nil
250}
251
252const (
253 oneSecond = 1

Callers

nothing calls this directly

Calls 5

DriversMethod · 0.65
GetLogSourceMethod · 0.65
CreateMethod · 0.65
DynamicMethod · 0.65
OnlineMethod · 0.65

Tested by

no test coverage detected