notify

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerCheckerName  = "__HealthChecker__"
	ServerCheckSubject = "__NotifyServerHealthCheck__"
)
View Source
const (
	DefaultQueueSize = 1000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event interface {
	Type() Type
	Subject() string // required!
	Group() string   // broadcast all the subscriber of the same subject if group is empty
	CreateAt() time.Time
}

func NewEvent

func NewEvent(t Type, s, g string) Event

func NewEventWithTime

func NewEventWithTime(t Type, s, g string, now simple.Time) Event

type Group

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

func NewGroup

func NewGroup(name string) *Group

func (*Group) AddSubscriber

func (g *Group) AddSubscriber(subscriber Subscriber) Subscriber

func (*Group) Name

func (g *Group) Name() string

func (*Group) Notify

func (g *Group) Notify(job Event)

func (*Group) Remove

func (g *Group) Remove(name string)

func (*Group) Size

func (g *Group) Size() int

func (*Group) Subscribers

func (g *Group) Subscribers(name string) Subscriber

type Processor

type Processor struct {
	*queue.TaskQueue
	// contains filtered or unexported fields
}

func NewProcessor

func NewProcessor(name string, queueSize int) *Processor

func (*Processor) Accept

func (p *Processor) Accept(job Event)

func (*Processor) AddSubscriber

func (p *Processor) AddSubscriber(n Subscriber)

func (*Processor) Clear

func (p *Processor) Clear()

func (*Processor) Handle

func (p *Processor) Handle(ctx context.Context, obj interface{})

func (*Processor) Name

func (p *Processor) Name() string

func (*Processor) Notify

func (p *Processor) Notify(job Event)

func (*Processor) Remove

func (p *Processor) Remove(n Subscriber)

func (*Processor) Subjects

func (p *Processor) Subjects(name string) *Subject

type Service

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

func NewNotifyService

func NewNotifyService() *Service

func (*Service) AddSubscriber

func (s *Service) AddSubscriber(n Subscriber) error

func (*Service) Closed

func (s *Service) Closed() (b bool)

func (*Service) Publish

func (s *Service) Publish(job Event) error

通知内容塞到队列里

func (*Service) RemoveSubscriber

func (s *Service) RemoveSubscriber(n Subscriber)

func (*Service) Start

func (s *Service) Start()

func (*Service) Stop

func (s *Service) Stop()

type ServiceHealthCheckJob

type ServiceHealthCheckJob struct {
	Event
	ErrorSubscriber Subscriber
}

func NewNotifyServiceHealthCheckJob

func NewNotifyServiceHealthCheckJob(s Subscriber) *ServiceHealthCheckJob

type ServiceHealthChecker

type ServiceHealthChecker struct {
	Subscriber
}

Notifier 健康检查

func NewNotifyServiceHealthChecker

func NewNotifyServiceHealthChecker() *ServiceHealthChecker

func (*ServiceHealthChecker) OnMessage

func (s *ServiceHealthChecker) OnMessage(job Event)

type Subject

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

func NewSubject

func NewSubject(name string) *Subject

func (*Subject) GetOrNewGroup

func (s *Subject) GetOrNewGroup(name string) *Group

func (*Subject) Groups

func (s *Subject) Groups(name string) *Group

func (*Subject) Name

func (s *Subject) Name() string

func (*Subject) Notify

func (s *Subject) Notify(job Event)

func (*Subject) Remove

func (s *Subject) Remove(name string)

func (*Subject) Size

func (s *Subject) Size() int

type Subscriber

type Subscriber interface {
	ID() string
	Subject() string
	Group() string
	Type() Type
	Service() *Service
	SetService(*Service)

	Err() error
	SetError(err error)

	Close()
	OnAccept()
	// The event bus will callback this function, so it must be non-blocked.
	OnMessage(Event)
}

func NewSubscriber

func NewSubscriber(nType Type, subject, group string) Subscriber

type Type

type Type int
const (
	NOTIFTY Type = iota
)

func RegisterType

func RegisterType(name string, size int) Type

func Types

func Types() (ts []Type)

func (Type) IsValid

func (nt Type) IsValid() bool

func (Type) QueueSize

func (nt Type) QueueSize() (s int)

func (Type) String

func (nt Type) String() string

Jump to

Keyboard shortcuts

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