email

package module
v0.0.0-...-d597042 Latest Latest
Warning

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

Go to latest
Published: May 20, 2019 License: MIT Imports: 10 Imported by: 0

README

Email Service Example

A simple example gRPC based email service that sends emails via SMTP. Connections are kept open whilst sending email then closed for after 30 seconds of inactivity.

service Email {
  rpc Send (EmailRequest) returns (EmailResponse) {}
}

Config

You can set SMTP details with the following env vars.

SMTP_HOST=smtp.sendgrid.net
SMTP_PORT=2525
SMTP_USERNAME=apikey
SMTP_PASSWORD=somepassword

Set DEBUG=true to see timing and connection information

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterEmailServer

func RegisterEmailServer(s *grpc.Server, srv EmailServer)

Types

type Attachment

type Attachment struct {
	Filename             string   `protobuf:"bytes,1,opt,name=filename,proto3" json:"filename,omitempty"`
	Body                 []byte   `protobuf:"bytes,2,opt,name=body,proto3" json:"body,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Attachment) Descriptor

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

func (*Attachment) GetBody

func (m *Attachment) GetBody() []byte

func (*Attachment) GetFilename

func (m *Attachment) GetFilename() string

func (*Attachment) ProtoMessage

func (*Attachment) ProtoMessage()

func (*Attachment) Reset

func (m *Attachment) Reset()

func (*Attachment) String

func (m *Attachment) String() string

func (*Attachment) XXX_DiscardUnknown

func (m *Attachment) XXX_DiscardUnknown()

func (*Attachment) XXX_Marshal

func (m *Attachment) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Attachment) XXX_Merge

func (m *Attachment) XXX_Merge(src proto.Message)

func (*Attachment) XXX_Size

func (m *Attachment) XXX_Size() int

func (*Attachment) XXX_Unmarshal

func (m *Attachment) XXX_Unmarshal(b []byte) error

type EmailClient

type EmailClient interface {
	Send(ctx context.Context, in *EmailRequest, opts ...grpc.CallOption) (*EmailResponse, error)
}

EmailClient is the client API for Email service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

var (
	Client EmailClient
)

func GetEmailClient

func GetEmailClient() EmailClient

func NewEmailClient

func NewEmailClient(cc *grpc.ClientConn) EmailClient

type EmailRequest

type EmailRequest struct {
	From                 string            `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"`
	To                   []string          `protobuf:"bytes,2,rep,name=to,proto3" json:"to,omitempty"`
	Subject              string            `protobuf:"bytes,3,opt,name=subject,proto3" json:"subject,omitempty"`
	PlainText            string            `protobuf:"bytes,4,opt,name=plain_text,json=plainText,proto3" json:"plain_text,omitempty"`
	HtmlAlternate        string            `protobuf:"bytes,5,opt,name=html_alternate,json=htmlAlternate,proto3" json:"html_alternate,omitempty"`
	Attachments          []*Attachment     `protobuf:"bytes,6,rep,name=attachments,proto3" json:"attachments,omitempty"`
	Headers              map[string]string `` /* 155-byte string literal not displayed */
	XXX_NoUnkeyedLiteral struct{}          `json:"-"`
	XXX_unrecognized     []byte            `json:"-"`
	XXX_sizecache        int32             `json:"-"`
}

func (*EmailRequest) Descriptor

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

func (*EmailRequest) GetAttachments

func (m *EmailRequest) GetAttachments() []*Attachment

func (*EmailRequest) GetFrom

func (m *EmailRequest) GetFrom() string

func (*EmailRequest) GetHeaders

func (m *EmailRequest) GetHeaders() map[string]string

func (*EmailRequest) GetHtmlAlternate

func (m *EmailRequest) GetHtmlAlternate() string

func (*EmailRequest) GetPlainText

func (m *EmailRequest) GetPlainText() string

func (*EmailRequest) GetSubject

func (m *EmailRequest) GetSubject() string

func (*EmailRequest) GetTo

func (m *EmailRequest) GetTo() []string

func (*EmailRequest) ProtoMessage

func (*EmailRequest) ProtoMessage()

func (*EmailRequest) Reset

func (m *EmailRequest) Reset()

func (*EmailRequest) String

func (m *EmailRequest) String() string

func (*EmailRequest) XXX_DiscardUnknown

func (m *EmailRequest) XXX_DiscardUnknown()

func (*EmailRequest) XXX_Marshal

func (m *EmailRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*EmailRequest) XXX_Merge

func (m *EmailRequest) XXX_Merge(src proto.Message)

func (*EmailRequest) XXX_Size

func (m *EmailRequest) XXX_Size() int

func (*EmailRequest) XXX_Unmarshal

func (m *EmailRequest) XXX_Unmarshal(b []byte) error

type EmailResponse

type EmailResponse struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*EmailResponse) Descriptor

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

func (*EmailResponse) ProtoMessage

func (*EmailResponse) ProtoMessage()

func (*EmailResponse) Reset

func (m *EmailResponse) Reset()

func (*EmailResponse) String

func (m *EmailResponse) String() string

func (*EmailResponse) XXX_DiscardUnknown

func (m *EmailResponse) XXX_DiscardUnknown()

func (*EmailResponse) XXX_Marshal

func (m *EmailResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*EmailResponse) XXX_Merge

func (m *EmailResponse) XXX_Merge(src proto.Message)

func (*EmailResponse) XXX_Size

func (m *EmailResponse) XXX_Size() int

func (*EmailResponse) XXX_Unmarshal

func (m *EmailResponse) XXX_Unmarshal(b []byte) error

type EmailServer

type EmailServer interface {
	Send(context.Context, *EmailRequest) (*EmailResponse, error)
}

EmailServer is the server API for Email service.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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