// Code generated by protoc-gen-go-ttrpc. DO NOT EDIT.
// source: health.proto
package grpc

import (
	context "context"
	ttrpc "github.com/containerd/ttrpc"
)

type HealthService interface {
	Check(context.Context, *CheckRequest) (*HealthCheckResponse, error)
	Version(context.Context, *CheckRequest) (*VersionCheckResponse, error)
}

func RegisterHealthService(srv *ttrpc.Server, svc HealthService) {
	srv.RegisterService("grpc.Health", &ttrpc.ServiceDesc{
		Methods: map[string]ttrpc.Method{
			"Check": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
				var req CheckRequest
				if err := unmarshal(&req); err != nil {
					return nil, err
				}
				return svc.Check(ctx, &req)
			},
			"Version": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
				var req CheckRequest
				if err := unmarshal(&req); err != nil {
					return nil, err
				}
				return svc.Version(ctx, &req)
			},
		},
	})
}

type healthClient struct {
	client *ttrpc.Client
}

func NewHealthClient(client *ttrpc.Client) HealthService {
	return &healthClient{
		client: client,
	}
}

func (c *healthClient) Check(ctx context.Context, req *CheckRequest) (*HealthCheckResponse, error) {
	var resp HealthCheckResponse
	if err := c.client.Call(ctx, "grpc.Health", "Check", req, &resp); err != nil {
		return nil, err
	}
	return &resp, nil
}

func (c *healthClient) Version(ctx context.Context, req *CheckRequest) (*VersionCheckResponse, error) {
	var resp VersionCheckResponse
	if err := c.client.Call(ctx, "grpc.Health", "Version", req, &resp); err != nil {
		return nil, err
	}
	return &resp, nil
}
