Documentation ¶
Index ¶
- Constants
- type ServicePubSubMessaging
- func (ps ServicePubSubMessaging) AddPubSubNamespace(topicName, serviceName string) string
- func (ps ServicePubSubMessaging) EnsureSubscriptionsExist(ctx context.Context) error
- func (ps ServicePubSubMessaging) EnsureTopicsExist(ctx context.Context, topicIDs []string) error
- func (ps ServicePubSubMessaging) NotifyFacilityFHIRIDUpdate(ctx context.Context, data dto.UpdateFacilityFHIRID) error
- func (ps ServicePubSubMessaging) NotifyPatientFHIRIDUpdate(ctx context.Context, data dto.UpdatePatientFHIRID) error
- func (ps ServicePubSubMessaging) NotifyProgramFHIRIDUpdate(ctx context.Context, data dto.UpdateProgramFHIRID) error
- func (ps ServicePubSubMessaging) PublishToPubsub(ctx context.Context, topicID, serviceName string, payload []byte) error
- func (ps ServicePubSubMessaging) SubscriptionIDs() map[string]string
- func (ps ServicePubSubMessaging) TopicIDs() []string
- type ServicePubsub
Constants ¶
const ( // HostNameEnvVarName defines the host name HostNameEnvVarName = "SERVICE_HOST" // TestTopicName is a topic that is used for testing purposes TestTopicName = "pubsub.testing.topic" TopicVersion = "v2" // MyCareHubServiceName defines the service where some of the topics have been created MyCareHubServiceName = "mycarehub" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ServicePubSubMessaging ¶
type ServicePubSubMessaging struct {
// contains filtered or unexported fields
}
ServicePubSubMessaging is used to send and receive pubsub notifications
func NewServicePubSubMessaging ¶
func NewServicePubSubMessaging( ctx context.Context, client *pubsub.Client, ) (*ServicePubSubMessaging, error)
NewServicePubSubMessaging returns a new instance of pubsub
func (ServicePubSubMessaging) AddPubSubNamespace ¶
func (ps ServicePubSubMessaging) AddPubSubNamespace(topicName, serviceName string) string
AddPubSubNamespace creates unique topics. The topics will be in the form <service name>-<topicName>-<environment>-v1
func (ServicePubSubMessaging) EnsureSubscriptionsExist ¶
func (ps ServicePubSubMessaging) EnsureSubscriptionsExist( ctx context.Context, ) error
EnsureSubscriptionsExist ensures that the subscriptions named in the supplied topic:subscription map exist. If any does not exist, it is created.
func (ServicePubSubMessaging) EnsureTopicsExist ¶
func (ps ServicePubSubMessaging) EnsureTopicsExist( ctx context.Context, topicIDs []string, ) error
EnsureTopicsExist creates the topic(s) in the supplied list if they do not exist
func (ServicePubSubMessaging) NotifyFacilityFHIRIDUpdate ¶ added in v1.0.0
func (ps ServicePubSubMessaging) NotifyFacilityFHIRIDUpdate(ctx context.Context, data dto.UpdateFacilityFHIRID) error
NotifyFacilityFHIRIDUpdate publishes to a topic. The idea is that after a mycarehub facility is created as an organization in FHIR, we should send back the ID to mycarehub and store in the database
func (ServicePubSubMessaging) NotifyPatientFHIRIDUpdate ¶ added in v1.0.0
func (ps ServicePubSubMessaging) NotifyPatientFHIRIDUpdate(ctx context.Context, data dto.UpdatePatientFHIRID) error
NotifyPatientFHIRIDUpdate publishes to patient fhir id update topic. Mycarehub service will subscribe to this topic and update the patient's FHIR ID in it's database
func (ServicePubSubMessaging) NotifyProgramFHIRIDUpdate ¶ added in v1.0.0
func (ps ServicePubSubMessaging) NotifyProgramFHIRIDUpdate(ctx context.Context, data dto.UpdateProgramFHIRID) error
NotifyProgramFHIRIDUpdate publishes to the program fhir id update topic
func (ServicePubSubMessaging) PublishToPubsub ¶
func (ps ServicePubSubMessaging) PublishToPubsub( ctx context.Context, topicID, serviceName string, payload []byte, ) error
PublishToPubsub publishes a message to a specified topic
func (ServicePubSubMessaging) SubscriptionIDs ¶
func (ps ServicePubSubMessaging) SubscriptionIDs() map[string]string
SubscriptionIDs returns a map of topic IDs to subscription IDs
func (ServicePubSubMessaging) TopicIDs ¶
func (ps ServicePubSubMessaging) TopicIDs() []string
TopicIDs returns the known (registered) topic IDs
type ServicePubsub ¶
type ServicePubsub interface { NotifyPatientFHIRIDUpdate(ctx context.Context, data dto.UpdatePatientFHIRID) error NotifyFacilityFHIRIDUpdate(ctx context.Context, data dto.UpdateFacilityFHIRID) error NotifyProgramFHIRIDUpdate(ctx context.Context, data dto.UpdateProgramFHIRID) error }