MCPcopy Create free account
hub / github.com/riverqueue/river / queueUpdate

Method queueUpdate

client.go:2873–2912  ·  view source on GitHub ↗
(ctx context.Context, executorTx riverdriver.ExecutorTx, name string, params *QueueUpdateParams)

Source from the content-addressed store, hash-verified

2871}
2872
2873func (c *Client[TTx]) queueUpdate(ctx context.Context, executorTx riverdriver.ExecutorTx, name string, params *QueueUpdateParams) (*rivertype.Queue, *controlEventPayload, error) {
2874 updateMetadata := len(params.Metadata) > 0
2875
2876 queue, err := executorTx.QueueUpdate(ctx, &riverdriver.QueueUpdateParams{
2877 Metadata: params.Metadata,
2878 MetadataDoUpdate: updateMetadata,
2879 Name: name,
2880 Schema: c.config.Schema,
2881 })
2882 if err != nil {
2883 return nil, nil, err
2884 }
2885
2886 if !updateMetadata {
2887 return queue, nil, err
2888 }
2889
2890 controlEvent := &controlEventPayload{
2891 Action: controlActionMetadataChanged,
2892 Metadata: params.Metadata,
2893 Queue: queue.Name,
2894 }
2895
2896 payload, err := json.Marshal(controlEvent)
2897 if err != nil {
2898 return nil, nil, err
2899 }
2900
2901 if c.driver.SupportsListenNotify() {
2902 if err := executorTx.NotifyMany(ctx, &riverdriver.NotifyManyParams{
2903 Payload: []string{string(payload)},
2904 Schema: c.config.Schema,
2905 Topic: string(notifier.NotificationTopicControl),
2906 }); err != nil {
2907 return nil, nil, err
2908 }
2909 }
2910
2911 return queue, controlEvent, nil
2912}
2913
2914// Schema returns the configured schema for the client.
2915func (c *Client[TTx]) Schema() string { return c.config.Schema }

Callers 2

QueueUpdateMethod · 0.95
QueueUpdateTxMethod · 0.95

Calls 3

QueueUpdateMethod · 0.65
SupportsListenNotifyMethod · 0.65
NotifyManyMethod · 0.65

Tested by

no test coverage detected