Skip to content

Commit 0088479

Browse files
committed
Rename pubsub variable in examples and comments
1 parent e734d92 commit 0088479

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ channel_routing = [
104104
```
105105

106106
## Publish-Subscribe
107-
Includes several publish-subscribe (pubsub) classes for hooking
107+
Included are several publish-subscribe (pubsub) classes for hooking
108108
up your mutations to your subscriptions. When a client makes a
109109
subscription, the pubsub can be used to map from one subscription name
110110
to one or more channel names to subscribe to the right channels.
@@ -127,7 +127,7 @@ from graphql_ws.pubsub import AsyncioPubsub
127127

128128
# create a new pubsub object; this class is in-memory and does
129129
# not utilze Redis
130-
p = AsyncioPubsub()
130+
pubsub = AsyncioPubsub()
131131

132132

133133
class MutationExample(graphene.Mutation):
@@ -138,7 +138,7 @@ class MutationExample(graphene.Mutation):
138138

139139
async def mutate(self, info, input_text):
140140
# publish to the pubsub object before returning mutation
141-
await p.publish('BASE', input_text)
141+
await pubsub.publish('BASE', input_text)
142142
return MutationExample(output_text=input_text)
143143

144144

@@ -153,14 +153,14 @@ class Subscription(graphene.ObjectType):
153153
try:
154154
# pubsub subscribe_to_channel method returns
155155
# subscription id and an asyncio.Queue
156-
sub_id, q = p.subscribe_to_channel('BASE')
156+
sub_id, q = pubsub.subscribe_to_channel('BASE')
157157
while True:
158158
payload = await q.get()
159159
yield payload
160160
except asyncio.CancelledError:
161161
# unsubscribe subscription id from channel
162162
# when coroutine is cancelled
163-
p.unsubscribe('BASE', sub_id)
163+
pubsub.unsubscribe('BASE', sub_id)
164164

165165
schema = graphene.Schema(mutation=Mutations,
166166
subscription=Subscription)
@@ -184,7 +184,7 @@ from rx import Observable
184184

185185
# create a new pubsub object; in the case you'll need to
186186
# be running a redis-server instance in a separate process
187-
p = GeventRxRedisPubsub()
187+
pubsub = GeventRxRedisPubsub()
188188

189189

190190
class MutationExample(graphene.Mutation):
@@ -195,7 +195,7 @@ class MutationExample(graphene.Mutation):
195195

196196
def mutate(self, info, input_text):
197197
# publish to the pubsub before returning mutation
198-
p.publish('BASE', input_text)
198+
pubsub.publish('BASE', input_text)
199199
return MutationExample(output_text=input_text)
200200

201201

@@ -208,9 +208,9 @@ class Subscription(graphene.ObjectType):
208208

209209
def resolve_mutation_example(root, info):
210210
# pubsub subscribe_to_channel method returns an observable
211-
# when observable is cancelled, the subscription will
211+
# when observable is disposed of, the subscription will
212212
# be cleaned up and unsubscribed from
213-
return p.subscribe_to_channel('BASE')\
213+
return pubsub.subscribe_to_channel('BASE')\
214214
.map(lambda i: "{0}".format(i))
215215

216216

examples/aiohttp/schema.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from graphql_ws.pubsub import AsyncioPubsub
66

7-
p = AsyncioPubsub()
7+
pubsub = AsyncioPubsub()
88

99

1010
class Query(graphene.ObjectType):
@@ -21,7 +21,7 @@ class Arguments:
2121
output_text = graphene.String()
2222

2323
async def mutate(self, info, input_text):
24-
await p.publish('BASE', input_text)
24+
await pubsub.publish('BASE', input_text)
2525
return MutationExample(output_text=input_text)
2626

2727

@@ -41,12 +41,12 @@ class Subscription(graphene.ObjectType):
4141

4242
async def resolve_mutation_example(root, info):
4343
try:
44-
sub_id, q = p.subscribe_to_channel('BASE')
44+
sub_id, q = pubsub.subscribe_to_channel('BASE')
4545
while True:
4646
payload = await q.get()
4747
yield payload
4848
finally:
49-
p.unsubscribe('BASE', sub_id)
49+
pubsub.unsubscribe('BASE', sub_id)
5050

5151
async def resolve_count_seconds(root, info, up_to=5):
5252
for i in range(up_to):

examples/flask_gevent/schema.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from graphql_ws.pubsub import GeventRxPubsub
55
from rx import Observable
66

7-
p = GeventRxPubsub()
7+
pubsub = GeventRxPubsub()
88

99

1010
class Query(graphene.ObjectType):
@@ -21,7 +21,7 @@ class Arguments:
2121
output_text = graphene.String()
2222

2323
def mutate(self, info, input_text):
24-
p.publish('BASE', input_text)
24+
pubsub.publish('BASE', input_text)
2525
return MutationExample(output_text=input_text)
2626

2727

@@ -41,7 +41,7 @@ class Subscription(graphene.ObjectType):
4141

4242
def resolve_mutation_example(root, info):
4343
# subscribe_to_channel method returns an observable
44-
return p.subscribe_to_channel('BASE')\
44+
return pubsub.subscribe_to_channel('BASE')\
4545
.map(lambda i: "{0}".format(i))
4646

4747
def resolve_count_seconds(root, info, up_to=5):

examples/websockets_lib/schema.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from graphql_ws.pubsub import AsyncioPubsub
66

7-
p = AsyncioPubsub()
7+
pubsub = AsyncioPubsub()
88

99

1010
class Query(graphene.ObjectType):
@@ -21,7 +21,7 @@ class Arguments:
2121
output_text = graphene.String()
2222

2323
async def mutate(self, info, input_text):
24-
await p.publish('BASE', input_text)
24+
await pubsub.publish('BASE', input_text)
2525
return MutationExample(output_text=input_text)
2626

2727

@@ -41,12 +41,12 @@ class Subscription(graphene.ObjectType):
4141

4242
async def resolve_mutation_example(root, info):
4343
try:
44-
sub_id, q = p.subscribe_to_channel('BASE')
44+
sub_id, q = pubsub.subscribe_to_channel('BASE')
4545
while True:
4646
payload = await q.get()
4747
yield payload
4848
finally:
49-
p.unsubscribe('BASE', sub_id)
49+
pubsub.unsubscribe('BASE', sub_id)
5050

5151
async def resolve_count_seconds(root, info, up_to=5):
5252
for i in range(up_to):

graphql_ws/pubsub/gevent_observable.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def subscribe_to_channel(self, channel):
4343
else:
4444
subject = Subject()
4545
# monkeypatch Subject to unsubscribe pubsub on observable
46-
# subscription.cancel()
46+
# subscription.dispose()
4747
subject.observers = SubjectObserversWrapper(self, channel)
4848
self.subscriptions[channel] = subject
4949
return subject
@@ -72,7 +72,7 @@ def subscribe_to_channel(self, channel):
7272
self.pubsub.subscribe(channel)
7373
subject = Subject()
7474
# monkeypatch Subject to unsubscribe pubsub on observable
75-
# subscription.cancel()
75+
# subscription.dispose()
7676
subject.observers = SubjectObserversWrapper(self, channel)
7777
self.subscriptions[channel] = subject
7878
if not self.greenlet:

0 commit comments

Comments
 (0)