Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / pigweed / repo / pw_metric / public / pw_metric / metric_service_nanopb.h
1 // Copyright 2020 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14 #pragma once
15
16 #include <cstring>
17 #include <span>
18
19 #include "pw_log/log.h"
20 #include "pw_metric/metric.h"
21 #include "pw_metric_proto/metric_service.rpc.pb.h"
22
23 namespace pw::metric {
24
25 // The MetricService will send metrics when requested by Get(). For now, each
26 // Get() request results in a stream of responses, containing the metrics from
27 // the supplied list of groups and metrics. This includes recursive traversal
28 // of subgroups. In the future, filtering will be supported.
29 //
30 // An important limitation of the current implementation is that the Get()
31 // method is blocking, and sends all metrics at once (though batched). In the
32 // future, we may switch to offering an async version where the Get() method
33 // returns immediately, and someone else is responsible for pumping the queue.
34 class MetricService final : public generated::MetricService<MetricService> {
35  public:
36   MetricService(const IntrusiveList<Metric>& metrics,
37                 const IntrusiveList<Group>& groups)
38       : metrics_(metrics), groups_(groups) {}
39
40   void Get(ServerContext&,
41            const pw_metric_MetricRequest& request,
42            ServerWriter<pw_metric_MetricResponse>& response);
43
44  private:
45   const IntrusiveList<Metric>& metrics_;
46   const IntrusiveList<Group>& groups_;
47 };
48
49 }  // namespace pw::metric