template

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PackagePathGoKitEndpoint      = "github.com/go-kit/kit/endpoint"
	PackagePathContext            = "context"
	PackagePathGoKitLog           = "github.com/go-kit/kit/log"
	PackagePathTime               = "time"
	PackagePathTransportLayer     = "github.com/devimteam/go-kit/transportlayer"
	PackagePathTransportLayerGRPC = "github.com/devimteam/go-kit/transportlayer/grpc"
	PackagePathGoogleGRPC         = "google.golang.org/grpc"
	PackagePathNetContext         = "golang.org/x/net/context"
)
View Source
const (
	MiddlewareTypeName = "Middleware"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientTemplate

type ClientTemplate struct {
}

func (ClientTemplate) Path

func (ClientTemplate) Path() string

func (ClientTemplate) Render

func (ClientTemplate) Render(i *parser.Interface) *File

Renders whole client file.

// This file was automatically generated by "microgen" utility.
// Please, do not edit.
package stringsvc

import (
	context "context"
	transportlayer "github.com/devimteam/go-kit/transportlayer/grpc"
)

type client struct {
	tc transportlayer.Client
}

func NewClient(tc transportlayer.Client) StringService {
	return &client{tc}
}

func (c *client) Count(ctx context.Context, text string, symbol string) (count int, positions []int) {
	req := CountRequest{
		Symbol: symbol,
		Text:   text,
	}
	resp, err := c.tc.Call(ctx, &req)
	if err != nil {
		return
	}
	return resp.(*CountResponse).Count, resp.(*CountResponse).Positions
}

type EndpointsTemplate

type EndpointsTemplate struct {
}

func (EndpointsTemplate) Path

func (EndpointsTemplate) Path() string

func (EndpointsTemplate) Render

func (EndpointsTemplate) Render(i *parser.Interface) *File

Renders endpoints file.

// This file was automatically generated by "microgen" utility.
// Please, do not edit.
package stringsvc

import (
	context "context"
	endpoint "github.com/go-kit/kit/endpoint"
)

type Endpoints struct {
	CountEndpoint endpoint.Endpoint
}

func (e *Endpoints) Count(ctx context.Context, text string, symbol string) (count int, positions []int) {
	req := CountRequest{
		Symbol: symbol,
		Text:   text,
	}
	resp, err := e.CountEndpoint(ctx, &req)
	if err != nil {
		return
	}
	return resp.(*CountResponse).Count, resp.(*CountResponse).Positions
}

func CountEndpoint(svc StringService) endpoint.Endpoint {
	return func(ctx context.Context, request interface{}) (interface{}, error) {
		req := request.(*CountRequest)
		count, positions := svc.Count(ctx, req.Text, req.Symbol)
		return &CountResponse{
			Count:     count,
			Positions: positions,
		}, nil
	}
}

type ExchangeTemplate

type ExchangeTemplate struct {
}

func (ExchangeTemplate) Path

func (ExchangeTemplate) Path() string

func (ExchangeTemplate) Render

func (ExchangeTemplate) Render(i *parser.Interface) *File

Renders exchanges file.

package visitsvc

import (
	"gitlab.devim.team/microservices/visitsvc/entity"
)

type CreateVisitRequest struct {
	Visit *entity.Visit `json:"visit"`
}

type CreateVisitResponse struct {
	Res *entity.Visit `json:"res"`
	Err error         `json:"err"`
}

type GRPCClientTemplate

type GRPCClientTemplate struct {
	PackagePath string
}

func (GRPCClientTemplate) Path

func (GRPCClientTemplate) Path() string

func (GRPCClientTemplate) Render

func (t GRPCClientTemplate) Render(i *parser.Interface) *File

Render whole grpc client file.

// This file was automatically generated by "microgen" utility.
// Please, do not edit.
package transportgrpc

import (
	transportlayer "github.com/devimteam/go-kit/transportlayer"
	grpc1 "github.com/devimteam/go-kit/transportlayer/grpc"
	svc "github.com/devimteam/microgen/test/svc"
	protobuf "github.com/devimteam/microgen/test/svc/transport/converter/protobuf"
	grpc "google.golang.org/grpc"
)

func NewClient(conn *grpc.ClientConn) svc.StringService {
	endpoints := []transportlayer.Endpoint{
		transportlayer.NewEndpoint(
			"Count",
			nil,
			transportlayer.WithConverter(protobuf.CountConverter),
		),
	}
	return svc.NewClient(
		grpc1.NewClient(
			"devim.string.protobuf.StringService",
			conn,
			endpoints,
		),
	)
}

type GRPCConverterTemplate

type GRPCConverterTemplate struct {
	PackagePath string
}

func (GRPCConverterTemplate) Path

func (GRPCConverterTemplate) Render

func (t GRPCConverterTemplate) Render(i *parser.Interface) *File

Renders converter file.

// This file was automatically generated by "microgen" utility.
// Please, do not edit.
package protobuf

import (
	context "context"
	grpc "github.com/devimteam/go-kit/transportlayer/grpc"
	svc "github.com/devimteam/microgen/test/svc"
	util "github.com/devimteam/microgen/test/svc/util"
	stringsvc "gitlab.devim.team/protobuf/stringsvc"
)

var CountConverter = &grpc.EndpointConverter{
	func(_ context.Context, request interface{}) (interface{}, error) {
		req := request.(*svc.CountRequest)
		return &stringsvc.CountRequest{
			Symbol: req.Symbol,
			Text:   req.Text,
		}, nil
	},
	func(_ context.Context, response interface{}) (interface{}, error) {
		resp := response.(*svc.CountResponse)
		respPositions, err := util.IntListToProto(resp.Positions)
		if err != nil {
			return nil, err
		}
		return &stringsvc.CountResponse{
			Count:     int64(resp.Count),
			Positions: respPositions,
		}, nil
	},
	func(_ context.Context, request interface{}) (interface{}, error) {
		req := request.(*stringsvc.CountRequest)
		return &svc.CountRequest{
			Symbol: string(req.Symbol),
			Text:   string(req.Text),
		}, nil
	},
	func(_ context.Context, response interface{}) (interface{}, error) {
		resp := response.(*stringsvc.CountResponse)
		respPositions, err := util.ProtoToIntList(resp.Positions)
		if err != nil {
			return nil, err
		}
		return &svc.CountResponse{
			Count:     int(resp.Count),
			Positions: respPositions,
		}, nil
	},
	stringsvc.CountResponse{},
}

type GRPCServerTemplate

type GRPCServerTemplate struct {
}

func (GRPCServerTemplate) Path

func (GRPCServerTemplate) Path() string

func (GRPCServerTemplate) Render

func (GRPCServerTemplate) Render(i *parser.Interface) *File

Render whole grpc server file.

// This file was automatically generated by "microgen" utility.
// Please, do not edit.
package transportgrpc

import (
	transportlayer "github.com/devimteam/go-kit/transportlayer/grpc"
	stringsvc "gitlab.devim.team/protobuf/stringsvc"
	context "golang.org/x/net/context"
)

type server struct {
	ts transportlayer.Server
}

func NewServer(endpoints []transportlayer.Endpoint) stringsvc.StringServiceServer {
	return &server{transportlayer.NewServer(endpoints)}
}

func (s *server) Count(ctx context.Context, req *stringsvc.CountRequest) (*stringsvc.CountResponse, error) {
	_, resp, err := s.ts.Serve(ctx, req)
	if err != nil {
		return nil, err
	}
	return resp.(*stringsvc.CountResponse), nil
}

type LoggingTemplate

type LoggingTemplate struct {
	PackagePath string
}

func (LoggingTemplate) Path

func (LoggingTemplate) Path() string

func (LoggingTemplate) Render

func (t LoggingTemplate) Render(i *parser.Interface) *File

Render all logging.go file.

// This file was automatically generated by "microgen" utility.
// Please, do not edit.
package middleware

import (
	context "context"
	svc "github.com/devimteam/microgen/test/svc"
	log "github.com/go-kit/kit/log"
	time "time"
)

func ServiceLogging(logger log.Logger) Middleware {
	return func(next svc.StringService) svc.StringService {
		return &serviceLogging{
			logger: logger,
			next:   next,
		}
	}
}

type serviceLogging struct {
	logger log.Logger
	next   svc.StringService
}

func (s *serviceLogging) Count(ctx context.Context, text string, symbol string) (count int, positions []int) {
	defer func(begin time.Time) {
		s.logger.Log(
			"method", "Count",
			"text", text,
			"symbol", symbol,
			"count", count,
			"positions", positions,
			"took", time.Since(begin))
	}(time.Now())
	return s.next.Count(ctx, text, symbol)
}

type MiddlewareTemplate

type MiddlewareTemplate struct {
	PackagePath string
}

func (MiddlewareTemplate) Path

func (MiddlewareTemplate) Path() string

func (MiddlewareTemplate) Render

func (t MiddlewareTemplate) Render(i *parser.Interface) *File

Render middleware decorator

// This file was automatically generated by "microgen" utility.
// Please, do not edit.
package middleware

import svc "github.com/devimteam/microgen/test/svc"

type Middleware func(svc.StringService) svc.StringService

Jump to

Keyboard shortcuts

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