health_watch_server.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Licensed to the LF AI & Data foundation under one
  2. // or more contributor license agreements. See the NOTICE file
  3. // distributed with this work for additional information
  4. // regarding copyright ownership. The ASF licenses this file
  5. // to you under the Apache License, Version 2.0 (the
  6. // "License"); you may not use this file except in compliance
  7. // with the License. You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. package mock
  17. import (
  18. "context"
  19. "google.golang.org/grpc/health/grpc_health_v1"
  20. "google.golang.org/grpc/metadata"
  21. )
  22. type GrpcHealthWatchServer struct {
  23. chanResult chan *grpc_health_v1.HealthCheckResponse
  24. }
  25. func NewGrpcHealthWatchServer() *GrpcHealthWatchServer {
  26. return &GrpcHealthWatchServer{
  27. chanResult: make(chan *grpc_health_v1.HealthCheckResponse, 1),
  28. }
  29. }
  30. func (m GrpcHealthWatchServer) Send(response *grpc_health_v1.HealthCheckResponse) error {
  31. m.chanResult <- response
  32. return nil
  33. }
  34. func (m GrpcHealthWatchServer) Chan() <-chan *grpc_health_v1.HealthCheckResponse {
  35. return m.chanResult
  36. }
  37. func (m GrpcHealthWatchServer) SetHeader(md metadata.MD) error {
  38. return nil
  39. }
  40. func (m GrpcHealthWatchServer) SendHeader(md metadata.MD) error {
  41. return nil
  42. }
  43. func (m GrpcHealthWatchServer) SetTrailer(md metadata.MD) {
  44. }
  45. func (m GrpcHealthWatchServer) Context() context.Context {
  46. return nil
  47. }
  48. func (m GrpcHealthWatchServer) SendMsg(msg interface{}) error {
  49. return nil
  50. }
  51. func (m GrpcHealthWatchServer) RecvMsg(msg interface{}) error {
  52. return nil
  53. }