api

package
v2.1.1-0...-182a82a Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2021 License: MIT Imports: 6 Imported by: 0

README

API

This package contains API artifacts such as protobuf annotations.

Protobuf Usage

  1. Define your gRPC service using protocol buffers

    your_service.proto:

    syntax = "proto3";
    package example;
    message StringMessage {
      string value = 1;
    }
    
    service YourService {
      rpc Echo(StringMessage) returns (StringMessage) {}
    }
    
  2. Add a semaphore.api annotation to your .proto file

    your_service.proto:

     syntax = "proto3";
     package example;
    +
    +import "semaphore/api/annotations.proto";
    +
     message StringMessage {
       string value = 1;
     }
    
     service YourService {
    +  option (semaphore.api.service) = {
    +    host: "127.0.0.1:80"
    +    transport: "http"
    +    codec: "json"
    +  };
    +
    -  rpc Echo(StringMessage) returns (StringMessage) {}
    +  rpc Echo(StringMessage) returns (StringMessage) {
    +    option (semaphore.api.http) = {
    +      post: "/v1/example/echo"
    +      body: "*"
    +    };
    +  }
     }
    

    You will need to provide the required third party protobuf files to the protoc compiler. They are included in this repo under the api folder, and we recommend copying them into your protoc generation file structure. If you've structured your protofiles according to something like the Buf style guide, you could copy the files into a top-level ./semaphore folder.

    If you do not want to modify the proto file for use with grpc-gateway you can alternatively use an external Service Configuration file. Check our documentation for more information.

  3. Write flow your definitions as usual

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// optional semaphore.api.HTTP http = 50011;
	E_Http = &file_api_annotations_proto_extTypes[1]
)

Extension fields to descriptor.MethodOptions.

View Source
var (
	// optional semaphore.api.Service service = 50012;
	E_Service = &file_api_annotations_proto_extTypes[0]
)

Extension fields to descriptor.ServiceOptions.

View Source
var File_api_annotations_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type HTTP

type HTTP struct {
	Endpoint string `protobuf:"bytes,1,opt,name=endpoint,proto3" json:"endpoint,omitempty"`
	Method   string `protobuf:"bytes,2,opt,name=method,proto3" json:"method,omitempty"`
	// contains filtered or unexported fields
}

func (*HTTP) Descriptor deprecated

func (*HTTP) Descriptor() ([]byte, []int)

Deprecated: Use HTTP.ProtoReflect.Descriptor instead.

func (*HTTP) GetEndpoint

func (x *HTTP) GetEndpoint() string

func (*HTTP) GetMethod

func (x *HTTP) GetMethod() string

func (*HTTP) ProtoMessage

func (*HTTP) ProtoMessage()

func (*HTTP) ProtoReflect

func (x *HTTP) ProtoReflect() protoreflect.Message

func (*HTTP) Reset

func (x *HTTP) Reset()

func (*HTTP) String

func (x *HTTP) String() string

type Service

type Service struct {
	Package       string `protobuf:"bytes,1,opt,name=package,proto3" json:"package,omitempty"`
	Name          string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	Host          string `protobuf:"bytes,3,opt,name=host,proto3" json:"host,omitempty"`
	Transport     string `protobuf:"bytes,4,opt,name=transport,proto3" json:"transport,omitempty"`
	Codec         string `protobuf:"bytes,5,opt,name=codec,proto3" json:"codec,omitempty"`
	RequestCodec  string `protobuf:"bytes,6,opt,name=request_codec,json=requestCodec,proto3" json:"request_codec,omitempty"`
	ResponseCodec string `protobuf:"bytes,7,opt,name=response_codec,json=responseCodec,proto3" json:"response_codec,omitempty"`
	// contains filtered or unexported fields
}

func (*Service) Descriptor deprecated

func (*Service) Descriptor() ([]byte, []int)

Deprecated: Use Service.ProtoReflect.Descriptor instead.

func (*Service) GetCodec

func (x *Service) GetCodec() string

func (*Service) GetHost

func (x *Service) GetHost() string

func (*Service) GetName

func (x *Service) GetName() string

func (*Service) GetPackage

func (x *Service) GetPackage() string

func (*Service) GetRequestCodec

func (x *Service) GetRequestCodec() string

func (*Service) GetResponseCodec

func (x *Service) GetResponseCodec() string

func (*Service) GetTransport

func (x *Service) GetTransport() string

func (*Service) ProtoMessage

func (*Service) ProtoMessage()

func (*Service) ProtoReflect

func (x *Service) ProtoReflect() protoreflect.Message

func (*Service) Reset

func (x *Service) Reset()

func (*Service) String

func (x *Service) String() string

Jump to

Keyboard shortcuts

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