MCPcopy Create free account
hub / github.com/GoogleChrome/webstatus.dev / Publish

Method Publish

lib/gcppubsub/client.go:45–61  ·  view source on GitHub ↗
(ctx context.Context, topicID string, data []byte)

Source from the content-addressed store, hash-verified

43}
44
45func (c *Client) Publish(ctx context.Context, topicID string, data []byte) (string, error) {
46 p := c.client.Publisher(topicID)
47
48 // Publish returns a Result which we must wait on.
49 // nolint:exhaustruct // WONTFIX: external struct
50 result := p.Publish(ctx, &pubsub.Message{
51 Data: data,
52 })
53
54 // Block until the result is returned (synchronous publish for safety)
55 id, err := result.Get(ctx)
56 if err != nil {
57 return "", errors.Join(ErrFailedToPublishMessage, err)
58 }
59
60 return id, nil
61}
62
63func (c *Client) Subscribe(ctx context.Context, subID string,
64 handler func(ctx context.Context, msgID string, data []byte) error) error {

Callers

nothing calls this directly

Calls 2

PublishMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected