examples

package
v0.74.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

README

Running the example

The example consists of a service and its client implementation. The service implementation uses the following components:

  • HTTP
  • gRPC
  • Kafka
  • AWS SQS
  • AMQP

The client implements all Patron clients for the components used by the service. There is also a flag that allows targeting a specific service component.

How to run

First we need to start the dependencies of the example by running:

make deps-start

Next we run the service:

make example-service

and afterwards the client:

make example-client

Documentation

Index

Constants

View Source
const (
	HTTPPort = "50001"
	HTTPURL  = "http://localhost:50001"

	GRPCPort   = "50002"
	GRPCTarget = "localhost:50002"

	AMQPURL          = "amqp://bitnami:bitnami@localhost:5672/"
	AMQPQueue        = "patron"
	AMQPExchangeName = "patron"
	AMQPExchangeType = amqp.ExchangeFanout

	AWSRegion      = "eu-west-1"
	AWSID          = "test"
	AWSSecret      = "test"
	AWSToken       = "token"
	AWSSQSEndpoint = "http://localhost:4566"
	AWSSQSQueue    = "patron"

	KafkaTopic  = "patron-topic"
	KafkaGroup  = "patron-group"
	KafkaBroker = "localhost:9092"
)

Variables

View Source
var File_greeter_proto protoreflect.FileDescriptor
View Source
var Greeter_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "examples.Greeter",
	HandlerType: (*GreeterServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "SayHello",
			Handler:    _Greeter_SayHello_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "SayHelloStream",
			Handler:       _Greeter_SayHelloStream_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "greeter.proto",
}

Greeter_ServiceDesc is the grpc.ServiceDesc for Greeter service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func CreateSQSConfig added in v0.74.0

func CreateSQSConfig() (aws.Config, error)

func RegisterGreeterServer added in v0.51.0

func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer)

Types

type GreeterClient added in v0.51.0

type GreeterClient interface {
	SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error)
	SayHelloStream(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (Greeter_SayHelloStreamClient, error)
}

GreeterClient is the client API for Greeter service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewGreeterClient added in v0.51.0

func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient

type GreeterServer added in v0.51.0

type GreeterServer interface {
	SayHello(context.Context, *HelloRequest) (*HelloReply, error)
	SayHelloStream(*HelloRequest, Greeter_SayHelloStreamServer) error
	// contains filtered or unexported methods
}

GreeterServer is the server API for Greeter service. All implementations must embed UnimplementedGreeterServer for forward compatibility

type Greeter_SayHelloStreamClient added in v0.51.0

type Greeter_SayHelloStreamClient interface {
	Recv() (*HelloReply, error)
	grpc.ClientStream
}

type Greeter_SayHelloStreamServer added in v0.51.0

type Greeter_SayHelloStreamServer interface {
	Send(*HelloReply) error
	grpc.ServerStream
}

type HelloReply added in v0.51.0

type HelloReply struct {
	Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
	// contains filtered or unexported fields
}

The response message containing the greetings

func (*HelloReply) Descriptor deprecated added in v0.51.0

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

Deprecated: Use HelloReply.ProtoReflect.Descriptor instead.

func (*HelloReply) GetMessage added in v0.51.0

func (x *HelloReply) GetMessage() string

func (*HelloReply) ProtoMessage added in v0.51.0

func (*HelloReply) ProtoMessage()

func (*HelloReply) ProtoReflect added in v0.65.0

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

func (*HelloReply) Reset added in v0.51.0

func (x *HelloReply) Reset()

func (*HelloReply) String added in v0.51.0

func (x *HelloReply) String() string

type HelloRequest added in v0.51.0

type HelloRequest struct {
	Firstname string `protobuf:"bytes,1,opt,name=firstname,proto3" json:"firstname,omitempty"`
	Lastname  string `protobuf:"bytes,2,opt,name=lastname,proto3" json:"lastname,omitempty"`
	// contains filtered or unexported fields
}

The request message containing the user's name.

func (*HelloRequest) Descriptor deprecated added in v0.51.0

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

Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead.

func (*HelloRequest) GetFirstname added in v0.51.0

func (x *HelloRequest) GetFirstname() string

func (*HelloRequest) GetLastname added in v0.51.0

func (x *HelloRequest) GetLastname() string

func (*HelloRequest) ProtoMessage added in v0.51.0

func (*HelloRequest) ProtoMessage()

func (*HelloRequest) ProtoReflect added in v0.65.0

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

func (*HelloRequest) Reset added in v0.51.0

func (x *HelloRequest) Reset()

func (*HelloRequest) String added in v0.51.0

func (x *HelloRequest) String() string

type UnimplementedGreeterServer added in v0.51.0

type UnimplementedGreeterServer struct {
}

UnimplementedGreeterServer must be embedded to have forward compatible implementations.

func (UnimplementedGreeterServer) SayHello added in v0.51.0

func (UnimplementedGreeterServer) SayHelloStream added in v0.51.0

type UnsafeGreeterServer added in v0.65.0

type UnsafeGreeterServer interface {
	// contains filtered or unexported methods
}

UnsafeGreeterServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to GreeterServer will result in compilation errors.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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