sendmail

package
v2.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: MIT Imports: 9 Imported by: 0

README

Sendmail

This example illustrate the usage of:

How to run:

  1. You need to run ../docker-services first.
  2. make to build client/server binary.
  3. Fill ./server/conf.json. (e.g. smtp/user settings ...)
  4. Run server: cd server && ./server
  5. Run client: cd client && ./client, then you can issue commands like this:

Client Commands

Example tracing output:

Trace

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EmailEntry_Status_name = map[int32]string{
		0: "SENDING",
		1: "SUCCESS",
		2: "FAILED",
	}
	EmailEntry_Status_value = map[string]int32{
		"SENDING": 0,
		"SUCCESS": 1,
		"FAILED":  2,
	}
)

Enum value maps for EmailEntry_Status.

View Source
var (
	// QueueSpec is the msg spec for publisher/subscriber.
	QueueSpec = EmailEntrySpec("sendmail.queue")
)
View Source
var (
	// SvcSpec is the service spec for rpc server/client.
	SvcSpec = NewSendMailSvcSpec("sendmail")
)

Functions

func PublishEmailEntry

func PublishEmailEntry(
	publisher msg.MsgPublisher,
	ctx context.Context,
	spec EmailEntrySpec,
	msg *EmailEntry,
) error

PublishEmailEntry publish a EmailEntry message.

func ServeSendMailSvc

func ServeSendMailSvc(server rpc.RPCServer, svcSpec *SendMailSvcSpec, svc SendMailSvc) (err error)

ServeSendMailSvc serves SendMailSvc service using a RPCServer.

func SubscribeEmailEntry

func SubscribeEmailEntry(
	subscriber msg.MsgSubscriber,
	spec EmailEntrySpec,
	queue string,
	handler func(context.Context, *EmailEntry) error,
	opts ...interface{}) error

SubscribeEmailEntry subscribes to a EmailEntry topic.

Types

type Email

type Email struct {

	// To email address.
	ToAddr string `protobuf:"bytes,1,opt,name=to_addr,json=toAddr,proto3" json:"to_addr,omitempty"`
	// To name.
	ToName string `protobuf:"bytes,2,opt,name=to_name,json=toName,proto3" json:"to_name,omitempty"`
	// Subject of email.
	Subject string `protobuf:"bytes,10,opt,name=subject,proto3" json:"subject,omitempty"`
	// ContentType is the mime type of email content. (e.g. text/html)
	ContentType string `protobuf:"bytes,11,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"`
	// Content is email content.
	Content string `protobuf:"bytes,12,opt,name=content,proto3" json:"content,omitempty"`
	// contains filtered or unexported fields
}

func (*Email) Descriptor deprecated

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

Deprecated: Use Email.ProtoReflect.Descriptor instead.

func (*Email) GetContent

func (x *Email) GetContent() string

func (*Email) GetContentType

func (x *Email) GetContentType() string

func (*Email) GetSubject

func (x *Email) GetSubject() string

func (*Email) GetToAddr

func (x *Email) GetToAddr() string

func (*Email) GetToName

func (x *Email) GetToName() string

func (*Email) ProtoMessage

func (*Email) ProtoMessage()

func (*Email) ProtoReflect

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

func (*Email) Reset

func (x *Email) Reset()

func (*Email) String

func (x *Email) String() string

type EmailEntries

type EmailEntries struct {
	Entries []*EmailEntry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"`
	// contains filtered or unexported fields
}

func (*EmailEntries) Descriptor deprecated

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

Deprecated: Use EmailEntries.ProtoReflect.Descriptor instead.

func (*EmailEntries) GetEntries

func (x *EmailEntries) GetEntries() []*EmailEntry

func (*EmailEntries) ProtoMessage

func (*EmailEntries) ProtoMessage()

func (*EmailEntries) ProtoReflect

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

func (*EmailEntries) Reset

func (x *EmailEntries) Reset()

func (*EmailEntries) String

func (x *EmailEntries) String() string

type EmailEntry

type EmailEntry struct {

	// Id is unique id of the email entry.
	Id     int64             `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	Status EmailEntry_Status `protobuf:"varint,2,opt,name=status,proto3,enum=nproto.demo.sendmail.EmailEntry_Status" json:"status,omitempty"`
	// CreatedAt is the time creating.
	CreatedAt string `protobuf:"bytes,3,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
	// EndedAt is the time success/failed.
	EndedAt string `protobuf:"bytes,4,opt,name=ended_at,json=endedAt,proto3" json:"ended_at,omitempty"`
	// FailedReason is sending error when failed.
	FailedReason string `protobuf:"bytes,5,opt,name=failed_reason,json=failedReason,proto3" json:"failed_reason,omitempty"`
	// Email is the concrete content.
	Email *Email `protobuf:"bytes,6,opt,name=email,proto3" json:"email,omitempty"`
	// contains filtered or unexported fields
}

@@npmsg@@

func (*EmailEntry) Descriptor deprecated

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

Deprecated: Use EmailEntry.ProtoReflect.Descriptor instead.

func (*EmailEntry) GetCreatedAt

func (x *EmailEntry) GetCreatedAt() string

func (*EmailEntry) GetEmail

func (x *EmailEntry) GetEmail() *Email

func (*EmailEntry) GetEndedAt

func (x *EmailEntry) GetEndedAt() string

func (*EmailEntry) GetFailedReason

func (x *EmailEntry) GetFailedReason() string

func (*EmailEntry) GetId

func (x *EmailEntry) GetId() int64

func (*EmailEntry) GetStatus

func (x *EmailEntry) GetStatus() EmailEntry_Status

func (*EmailEntry) ProtoMessage

func (*EmailEntry) ProtoMessage()

func (*EmailEntry) ProtoReflect

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

func (*EmailEntry) Reset

func (x *EmailEntry) Reset()

func (*EmailEntry) String

func (x *EmailEntry) String() string

type EmailEntrySpec

type EmailEntrySpec string

EmailEntrySpec implements msg.MsgSpec interface.

func (EmailEntrySpec) MsgType

func (spec EmailEntrySpec) MsgType() reflect.Type

MsgType returns reflect.TypeOf((*EmailEntry)(nil)).

func (EmailEntrySpec) MsgValue

func (spec EmailEntrySpec) MsgValue() interface{}

MsgValue returns a sample *EmailEntry.

func (EmailEntrySpec) NewMsg

func (spec EmailEntrySpec) NewMsg() interface{}

NewMsg returns new(EmailEntry).

func (EmailEntrySpec) SubjectName

func (spec EmailEntrySpec) SubjectName() string

SubjectName returns string(spec).

type EmailEntry_Status

type EmailEntry_Status int32

Status indicates the sending status.

const (
	EmailEntry_SENDING EmailEntry_Status = 0
	EmailEntry_SUCCESS EmailEntry_Status = 1
	EmailEntry_FAILED  EmailEntry_Status = 2
)

func (EmailEntry_Status) Descriptor

func (EmailEntry_Status) Enum

func (EmailEntry_Status) EnumDescriptor deprecated

func (EmailEntry_Status) EnumDescriptor() ([]byte, []int)

Deprecated: Use EmailEntry_Status.Descriptor instead.

func (EmailEntry_Status) Number

func (EmailEntry_Status) String

func (x EmailEntry_Status) String() string

func (EmailEntry_Status) Type

type SendMailSvc

type SendMailSvc interface {
	Send(context.Context, *Email) (*EmailEntry, error)

	List(context.Context, *empty.Empty) (*EmailEntries, error)
}

@@nprpc@@

func InvokeSendMailSvc

func InvokeSendMailSvc(client rpc.RPCClient, svcSpec *SendMailSvcSpec) SendMailSvc

InvokeSendMailSvc invokes SendMailSvc service using a RPCClient.

type SendMailSvcSpec

type SendMailSvcSpec struct {
	// contains filtered or unexported fields
}

SendMailSvcSpec contains method specs of service SendMailSvc.

func NewSendMailSvcSpec

func NewSendMailSvcSpec(svcName string) *SendMailSvcSpec

NewSendMailSvcSpec creates a new SendMailSvcSpec.

func (*SendMailSvcSpec) SpecMap

func (spec *SendMailSvcSpec) SpecMap() map[string]rpc.RPCSpec

SpecMap returns a mapping from method name to method spec.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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