push

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DeviceValidation is topic name for device validation messages
	DeviceValidation string = "DEVICE_VALIDATION"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	ID         string
	Attributes map[string]string
	LoggedInAt time.Time
}

Device struct for device and attrs

func (Device) ToProto

func (d Device) ToProto() *pushv1.Device

ToProto converts to proto

type GetClientActiveDevicesRequest

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

GetClientActiveDevicesRequest model

func (*GetClientActiveDevicesRequest) PopulateFromProto

PopulateFromProto maps model from proto

type SendEventToClientChannelRequest

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

SendEventToClientChannelRequest model

func (*SendEventToClientChannelRequest) PopulateFromProto

PopulateFromProto maps model from proto

type SendEventToClientDeviceChannelRequest

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

SendEventToClientDeviceChannelRequest model

func (*SendEventToClientDeviceChannelRequest) PopulateFromProto

PopulateFromProto maps model from proto

type SendEventToTopicRequest

type SendEventToTopicRequest struct {
	Topic     string
	EventName string
	Event     []byte
}

SendEventToTopicRequest model

func (*SendEventToTopicRequest) PopulateFromProto

func (smt *SendEventToTopicRequest) PopulateFromProto(ctx context.Context, protoRequest *pushv1.SendEventToTopicRequest) error

PopulateFromProto maps model from proto

type SendEventToTopicsRequest

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

SendEventToTopicsRequest model

func (*SendEventToTopicsRequest) PopulateFromProto

func (sm *SendEventToTopicsRequest) PopulateFromProto(ctx context.Context, proto *pushv1.SendEventToTopicsRequest) error

PopulateFromProto maps model from proto

type Service

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

Service of the push service

func NewService

func NewService(pubSub pubsub.IPubSub, kv kv.IKV, config config.Config) *Service

NewService returns a new instance of Service

func (*Service) AsyncClientSubscribe

func (c *Service) AsyncClientSubscribe(ctx context.Context, clientID string, device *Device) (*subscription.Subscription, error)

AsyncClientSubscribe to the client

func (*Service) ClientUnsubscribe

func (c *Service) ClientUnsubscribe(ctx context.Context, clientID string, subscription *subscription.Subscription, device *Device) error

ClientUnsubscribe unsubscribes a client

func (*Service) ConfirmEventReceipt

func (c *Service) ConfirmEventReceipt(ctx context.Context, eventName string)

ConfirmEventReceipt is just used for instrumentation

func (*Service) GetClientActiveDevices

func (c *Service) GetClientActiveDevices(ctx context.Context, req GetClientActiveDevicesRequest) ([]Device, error)

GetClientActiveDevices ...

                                      ┌──────┐
      2. subscribe(clnt, clnt-device) │      │◄──────────┐
                                 ┌───►│redis │           │
                  ┌───────────┐  │    │pubsub├──────┐    │
┌───┐             │           ├──┘    ├───▲──┘      │    │
│   │1. connect   │           │       │   │         │    │
│app├────────────►│propeller  │◄──────┘   │         │    │
│   │             │           │9.         │         │    │8.
└───┘             │           ├───────────┘         │    │
                  │           │10. validation resp  │    │validation
                  └───────────┴──┐    ┌───────┐     │    │message
                                 │    │       │     │    │published
   3. store(clnt, device, attrs) │    │ redis │     │    │
                                 └───►│  kv   │     │11. │
                                      │       │     │    │
                                      └───────┘     │    │
                    5. devices = load(clnt)         │    │
            13.delete stale entries   ┌──────┐      │    │
                  ┌────────────┐      │      │      │    │
                  │            ├─────►│redis │      │    │
┌───┐             │            │      │ kv   │      │    │
│   │4.getDevices │            │      └──────┘      │    │
│ BE├────────────►│propeller   │12. validation recv │    │
│   │             │            │◄─────┬──────┐      │    │
│   │14. reply    │            │6.    │      │◄─────┘    │
│   │◄────────────┤            ├─────►│redis │           │
└───┘             │            │7.    │pubsub├───────────┘
                  └────────────┴─────►└──────┘
        6. subscribe(clnt-device-resp)
   7. publishToTopic(clnt-device, validation message)

func (*Service) IsDeviceValidationMessage

func (c *Service) IsDeviceValidationMessage(eventName string) bool

IsDeviceValidationMessage checks if the message is device validation message

func (*Service) PublishToClient

func (c *Service) PublishToClient(ctx context.Context, req SendEventToClientChannelRequest) error

PublishToClient publishes to the client

func (*Service) PublishToClientWithDevice

func (c *Service) PublishToClientWithDevice(ctx context.Context, req SendEventToClientDeviceChannelRequest) error

PublishToClientWithDevice publishes to the client with device

func (*Service) PublishToTopic

func (c *Service) PublishToTopic(ctx context.Context, req SendEventToTopicRequest) error

PublishToTopic publishes to the topic

func (*Service) PublishToTopics

func (c *Service) PublishToTopics(ctx context.Context, req SendEventToTopicsRequest) error

PublishToTopics publishes to multiple topics in bulk

func (*Service) TopicSubscribe

func (c *Service) TopicSubscribe(ctx context.Context, topic string, clientSubscription *subscription.Subscription) error

TopicSubscribe to the topic

func (*Service) TopicUnsubscribe

func (c *Service) TopicUnsubscribe(ctx context.Context, topic string, clientSubscription *subscription.Subscription) error

TopicUnsubscribe to unsubscribe from a topic

func (*Service) TriggerTestPayloadToTopic

func (c *Service) TriggerTestPayloadToTopic(ctx context.Context, topic string)

TriggerTestPayloadToTopic triggers test payload to topic

type TopicSubscriptionRequest

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

TopicSubscriptionRequest model

type TopicUnSubscriptionRequest

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

TopicUnSubscriptionRequest model

Jump to

Keyboard shortcuts

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