MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / Subscribe

Method Subscribe

libs/pubsub/pubsub.go:149–163  ·  view source on GitHub ↗

Subscribe creates a subscription for the given client. An error will be returned to the caller if the context is canceled or if subscription already exist for pair clientID and query. outCapacity can be used to set a capacity for Subscription#Out channel (1 by default). Panics if outCapacity is le

(
	ctx context.Context,
	clientID string,
	query Query,
	outCapacity ...int)

Source from the content-addressed store, hash-verified

147// default). Panics if outCapacity is less than or equal to zero. If you want
148// an unbuffered channel, use SubscribeUnbuffered.
149func (s *Server) Subscribe(
150 ctx context.Context,
151 clientID string,
152 query Query,
153 outCapacity ...int) (*Subscription, error) {
154 outCap := 1
155 if len(outCapacity) > 0 {
156 if outCapacity[0] <= 0 {
157 panic("Negative or zero capacity. Use SubscribeUnbuffered if you want an unbuffered channel")
158 }
159 outCap = outCapacity[0]
160 }
161
162 return s.subscribe(ctx, clientID, query, outCap)
163}
164
165// SubscribeUnbuffered does the same as Subscribe, except it returns a
166// subscription with unbuffered channel. Use with caution as it can freeze the

Callers 13

TestSubscribeFunction · 0.95
TestDifferentClientsFunction · 0.95
TestUnsubscribeFunction · 0.95
TestResubscribeFunction · 0.95
TestUnsubscribeAllFunction · 0.95
benchmarkNClientsFunction · 0.95

Calls 1

subscribeMethod · 0.95

Tested by 13

TestSubscribeFunction · 0.76
TestDifferentClientsFunction · 0.76
TestUnsubscribeFunction · 0.76
TestResubscribeFunction · 0.76
TestUnsubscribeAllFunction · 0.76
benchmarkNClientsFunction · 0.76