input-api

command module
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

README

Input API

Build Proto and Swagger


cd ..
git clone https://gitlab.ixcloud.ch/ix.mercurius/common
cd common/proto
protoc -I. --go_out=plugins=grpc:${GOPATH}/src/ --grpc-gateway_out=logtostderr=true:${GOPATH}/src/  --swagger_out=logtostderr=true:. input-api.proto

# or using makefile
make generate

run Locally

make run

Healthcheck

This section describes, how the Healthcheck is implemented.

Local

To verify the local running instance the probe has to be installed and executed as shown below:

go get github.com/grpc-ecosystem/grpc-health-probe
$GOPATH/bin/grpc-health-probe -addr=localhost:8082
Configuration for application and Deployment

To make use of the Healthcheck some steps are needed. Attention: the golang section is configured to respond always positive.

# deployment yaml
        readinessProbe:
          exec:
            command: ["/bin/grpc_health_probe", "-addr=:8082"]
          initialDelaySeconds: 5
        livenessProbe:
          exec:
            command: ["/bin/grpc_health_probe", "-addr=:8082"]
          initialDelaySeconds: 10
# dockerfile
RUN GRPC_HEALTH_PROBE_VERSION=v0.3.1 && \
    wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
    chmod +x /bin/grpc_health_probe
// main.go
package main
import (
    health "google.golang.org/grpc/health/grpc_health_v1"
)

func main(){
    health.RegisterHealthServer(server, new(AlertService))
}

func (s *AlertService) Check(ctx context.Context, in *health.HealthCheckRequest) (*health.HealthCheckResponse, error) {
   return &health.HealthCheckResponse{Status: health.HealthCheckResponse_SERVING}, nil
}

func (s *AlertService) Watch(in *health.HealthCheckRequest, _ health.Health_WatchServer) error {
   // Example of how to register both methods but only implement the Check method.
   return status.Error(codes.Unimplemented, "unimplemented")
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL