rpc

package
v0.3.9-2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrSendServiceNotFound means SRpcService's SendSerivces hasn't this Send Service.
	ErrSendServiceNotFound = errors.Error("No such send service")
)

Variables

View Source
var ErrGetConfig = errors.Error("Get Config Failed")

Functions

This section is empty.

Types

type SRpcService

type SRpcService struct {
	SendServices *ServiceMap
	// contains filtered or unexported fields
}

SRpcService provide rpc service about sending message for notify module and manage these services. SendServices storage all send service.

func NewSRpcService

func NewSRpcService(socketFileDir string, configStore notifyv2.IServiceConfigStore,
	tempalteStore notifyv2.ITemplateStore) *SRpcService

NewSRpcService create a SRpcService

func (*SRpcService) AddConfig

func (self *SRpcService) AddConfig(ctx context.Context, service string, config notifyv2.SConfig) error

func (*SRpcService) BatchSend

func (self *SRpcService) BatchSend(ctx context.Context, contactType string, args apis.BatchSendParams) ([]*apis.FailedRecord, error)

func (*SRpcService) ContactByMobile

func (self *SRpcService) ContactByMobile(ctx context.Context, mobile, serviceName string, domainId string) (string, error)

func (*SRpcService) DeleteConfig

func (self *SRpcService) DeleteConfig(ctx context.Context, service, domainId string) error

func (*SRpcService) InitAll

func (self *SRpcService) InitAll() error

InitAll init all Send Services, the init process is that: find all socket file in directory 'self.socketFileDir', if wrong return error; the name of file is the service's name; then try to dial to this rpc service through corresponding socket file, if failed, only print log but not return error.

func (*SRpcService) Send

func (self *SRpcService) Send(ctx context.Context, contactType string, args apis.SendParams) error

Send call the corresponding rpc server to send messager.

func (*SRpcService) SendRobotMessage

func (self *SRpcService) SendRobotMessage(ctx context.Context, rType string, receivers []*apis.SReceiver, title string, message string) ([]*apis.FailedRecord, error)

func (*SRpcService) StopAll

func (self *SRpcService) StopAll()

StopAll stop all send service in self.SenderServices normally which can delete the socket file.

func (*SRpcService) UpdateConfig

func (self *SRpcService) UpdateConfig(ctx context.Context, service string, config notifyv2.SConfig) error

UpdateConfig can update config for rpc service with domainId

func (*SRpcService) UpdateServices

func (self *SRpcService) UpdateServices(ctx context.Context, usreCred mcclient.TokenCredential, isStart bool)

UpdateServices will detect the self.sockFileDir, add new service and delete disappeared one from self.SendServices.

func (*SRpcService) ValidateConfig

func (self *SRpcService) ValidateConfig(ctx context.Context, cType string, configs map[string]string) (isValid bool, message string, err error)

type ServiceMap

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

ServiceMap has a map of string and apis.SendNotification's pointer, and a RWMutex lock protect map.

func NewServiceMap

func NewServiceMap() *ServiceMap

func (*ServiceMap) BatchRemove

func (sm *ServiceMap) BatchRemove(serviceNames []string)

func (*ServiceMap) Get

func (sm *ServiceMap) Get(serviceName string) (*apis.SendNotificationClient, bool)

func (*ServiceMap) IsExist

func (sm *ServiceMap) IsExist(serviceName string) bool

func (*ServiceMap) Len

func (sm *ServiceMap) Len() int

func (*ServiceMap) Map

func (sm *ServiceMap) Map(f func(*apis.SendNotificationClient))

func (*ServiceMap) Remove

func (sm *ServiceMap) Remove(serviceName string)

func (*ServiceMap) ServiceNames

func (sm *ServiceMap) ServiceNames() []string

func (*ServiceMap) Set

func (sm *ServiceMap) Set(service *apis.SendNotificationClient, serviceName string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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