host

package
v0.0.0-...-73fb834 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2019 License: GPL-3.0 Imports: 4 Imported by: 0

README

gRPC API Service Hosting

Makes it easy to host a gRPC service in go.

Prereqs

To install, use the following:

go get google.golang.org/grpc
go get github.com/vigilantapps/viper-common/api/host

Example

import (
    "log"
    api "my/grpc/api"
    "github.com/vigilantapps/viper-common/api/host"
    "google.golang.org/grpc"
)

func main() {
    // init your service implementation struct
    impl := api.NewServerImpl{}

    // now host the service
    err := host.Service(8080, func(s *grpc.Server) {
        api.RegisterMyGrpcService(s, impl)
    })

    // if it can't be hosted, log the error and exit
    if err != nil {
        log.Fatalf("Unable to host service, %v", err)
    }
}

Documentation

Overview

Package host makes it easy to host grpc services in go. Simply call it with your registration callback like so:

err := host.Service(8080, func(s *grpc.Server) { api.RegisterGeocoderServer(s, impl) })

Will block until the service is cancelled.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Service

func Service(port int, registerCallback func(*grpc.Server)) error

Service hosts a grpc service on a given port

Types

This section is empty.

Jump to

Keyboard shortcuts

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