ably-pubsub-server 0.0.1.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +33 -0
- data/lib/ably/pubsub/server/version.rb +9 -0
- data/lib/ably/pubsub/server.rb +76 -0
- metadata +61 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: ad6b933bae9be99149ec75b5a4925fb23b3da6376ac216d04201d138238dfeea
|
|
4
|
+
data.tar.gz: d5c972097fc66b5433a8439de8f8489b2fbb56a42930cd7cc9b56aaf7e657c91
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e608ed19fb0ca50835a40b5dbdff61a61b367d2026853ccb4026c390f8b0017f152a6affba33efa2c06252616e5c37b4c029ade7494ad803d5d0715260ee5a44
|
|
7
|
+
data.tar.gz: a575114f1cd9570ec969eea1a52a829771cb3d4625efd0453006d67e0b701613938f3f10a6711b26ebe7ec72c1a9288cf79f72a515a8325d3980246df13a2039
|
data/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# ably-pubsub-server
|
|
2
|
+
|
|
3
|
+
Ably Pub/Sub client for servers: backend services and other trusted runtimes.
|
|
4
|
+
|
|
5
|
+
Installing this package declares that its traffic originates from the server side —
|
|
6
|
+
[MAU classification](https://ably.com/pricing) is a side effect of the install decision.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
gem 'ably-pubsub-server'
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
The factory functions are the only recommended entry points:
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
require 'ably/pubsub/server'
|
|
20
|
+
|
|
21
|
+
# Stateless HTTP client: publish, history, presence reads, token issuance
|
|
22
|
+
http_client = Ably::PubSub::Server.create_http_client('your-api-key')
|
|
23
|
+
http_client.channels.get('example').publish('event', 'payload')
|
|
24
|
+
|
|
25
|
+
# Stateful realtime client: a persistent, live connection (EventMachine-based)
|
|
26
|
+
realtime_client = Ably::PubSub::Server.create_realtime_client('your-api-key')
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Both factories accept everything the underlying constructors accept: an options `Hash`,
|
|
30
|
+
an API key `String`, or a token `String`.
|
|
31
|
+
|
|
32
|
+
This gem is built on `ably-pubsub-core`, an internal implementation package. Depend on
|
|
33
|
+
this gem, not on the core.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
require 'ably'
|
|
2
|
+
require 'ably/pubsub/server/version'
|
|
3
|
+
|
|
4
|
+
module Ably
|
|
5
|
+
module PubSub
|
|
6
|
+
# The Ably Pub/Sub SDK for servers. The factory functions here are the only
|
|
7
|
+
# recommended entry points of the +ably-pubsub-server+ gem.
|
|
8
|
+
module Server
|
|
9
|
+
# The agent identifier declaring the server side.
|
|
10
|
+
#
|
|
11
|
+
# The `-server` suffix is load-bearing, not cosmetic. On API-key auth the realtime
|
|
12
|
+
# system grants the MAU server exemption by matching an agent entry ending in
|
|
13
|
+
# `-server`, and an identifier that is not yet in the ably-common registry is
|
|
14
|
+
# classified by that suffix alone. Renaming it without preserving the suffix
|
|
15
|
+
# silently reclassifies every client this package constructs.
|
|
16
|
+
#
|
|
17
|
+
# The entry is stamped WITHOUT a version, matching its registration in the
|
|
18
|
+
# ably-common agents registry (a pure flag, like `browser`): under lockstep
|
|
19
|
+
# versioning a version here always duplicates the ably-pubsub-ruby entry beside it,
|
|
20
|
+
# which keeps carrying identity, version and support status. Wire shape:
|
|
21
|
+
# ably-pubsub-ruby/2.0.0 ruby/3.3.0 ably-pubsub-server
|
|
22
|
+
SERVER_AGENT_IDENTIFIER = 'ably-pubsub-server'
|
|
23
|
+
|
|
24
|
+
class << self
|
|
25
|
+
# Creates a stateless HTTP (REST) client declaring the server side.
|
|
26
|
+
#
|
|
27
|
+
# Accepts everything {Ably::Rest::Client#initialize} accepts: an options Hash,
|
|
28
|
+
# an API key String, or a token String.
|
|
29
|
+
#
|
|
30
|
+
# @return [Ably::Rest::Client]
|
|
31
|
+
def create_http_client(options)
|
|
32
|
+
Ably::Rest::Client.new(options_with_side_agent(options))
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Creates a stateful realtime client declaring the server side.
|
|
36
|
+
#
|
|
37
|
+
# Accepts everything {Ably::Realtime::Client#initialize} accepts: an options Hash,
|
|
38
|
+
# an API key String, or a token String.
|
|
39
|
+
#
|
|
40
|
+
# @return [Ably::Realtime::Client]
|
|
41
|
+
def create_realtime_client(options)
|
|
42
|
+
Ably::Realtime::Client.new(options_with_side_agent(options))
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
# Returns a copy of the caller's options carrying the agent entry that declares
|
|
48
|
+
# this package's side.
|
|
49
|
+
#
|
|
50
|
+
# The caller's own +:agents+ entries are preserved, so an SDK layered on top of
|
|
51
|
+
# this package keeps its attribution. The side entry is merged last and so wins a
|
|
52
|
+
# collision on its own identifier: which side the package declares is the
|
|
53
|
+
# package's to state, not the caller's to redefine.
|
|
54
|
+
#
|
|
55
|
+
# A nil argument passes through unchanged so the caller gets the core
|
|
56
|
+
# constructor's own initialization error rather than a vaguer failure later.
|
|
57
|
+
def options_with_side_agent(options)
|
|
58
|
+
return options if options.nil?
|
|
59
|
+
|
|
60
|
+
options = if options.kind_of?(String)
|
|
61
|
+
if options.match(Ably::Auth::API_KEY_REGEX)
|
|
62
|
+
{ key: options }
|
|
63
|
+
else
|
|
64
|
+
{ token: options }
|
|
65
|
+
end
|
|
66
|
+
else
|
|
67
|
+
options.clone
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
agents = options[:agents].to_h.merge(SERVER_AGENT_IDENTIFIER => nil)
|
|
71
|
+
options.merge(agents: agents)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ably-pubsub-server
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1.pre
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Ably
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-09-03 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: ably-pubsub-core
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - '='
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 0.0.1.pre
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - '='
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 0.0.1.pre
|
|
27
|
+
description: 'Ably Pub/Sub client for servers: backend services and other trusted
|
|
28
|
+
runtimes. Construct clients with Ably::PubSub::Server.create_http_client or Ably::PubSub::Server.create_realtime_client.'
|
|
29
|
+
email:
|
|
30
|
+
- support@ably.com
|
|
31
|
+
executables: []
|
|
32
|
+
extensions: []
|
|
33
|
+
extra_rdoc_files: []
|
|
34
|
+
files:
|
|
35
|
+
- README.md
|
|
36
|
+
- lib/ably/pubsub/server.rb
|
|
37
|
+
- lib/ably/pubsub/server/version.rb
|
|
38
|
+
homepage: https://github.com/ably/ably-pubsub-ruby
|
|
39
|
+
licenses:
|
|
40
|
+
- Apache-2.0
|
|
41
|
+
metadata: {}
|
|
42
|
+
post_install_message:
|
|
43
|
+
rdoc_options: []
|
|
44
|
+
require_paths:
|
|
45
|
+
- lib
|
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
47
|
+
requirements:
|
|
48
|
+
- - ">="
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: '0'
|
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - ">="
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '0'
|
|
56
|
+
requirements: []
|
|
57
|
+
rubygems_version: 3.5.22
|
|
58
|
+
signing_key:
|
|
59
|
+
specification_version: 4
|
|
60
|
+
summary: Ably Pub/Sub client for servers
|
|
61
|
+
test_files: []
|