NewService creates a new ORCA service implementation configured using the provided options.
(opts ServiceOptions)
| 92 | // NewService creates a new ORCA service implementation configured using the |
| 93 | // provided options. |
| 94 | func NewService(opts ServiceOptions) (*Service, error) { |
| 95 | // The default minimum supported reporting interval value can be overridden |
| 96 | // for testing purposes through the orca internal package. |
| 97 | if opts.ServerMetricsProvider == nil { |
| 98 | return nil, fmt.Errorf("ServerMetricsProvider not specified") |
| 99 | } |
| 100 | if !opts.allowAnyMinReportingInterval { |
| 101 | if opts.MinReportingInterval < 0 || opts.MinReportingInterval < minReportingInterval { |
| 102 | opts.MinReportingInterval = minReportingInterval |
| 103 | } |
| 104 | } |
| 105 | service := &Service{ |
| 106 | minReportingInterval: opts.MinReportingInterval, |
| 107 | smProvider: opts.ServerMetricsProvider, |
| 108 | } |
| 109 | return service, nil |
| 110 | } |
| 111 | |
| 112 | // Register creates a new ORCA service implementation configured using the |
| 113 | // provided options and registers the same on the provided grpc Server. |