nats-native 1.4.2
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/ext/nats/extconf.rb +4 -0
- data/ext/nats/nats.c +84 -0
- metadata +59 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: abb5c32131873c0aaa14167195df0ca4907e2b53
|
4
|
+
data.tar.gz: e9aef42d402f201419a0f388dc8761e80266ce94
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 37b54b49ff9c650799dbcb0a39050cd8846140535b8326e71513682cd9efda1ba37edf5d0e12489211223191680c62d8fe1dbff9542708ac49fb2dfd9a317cce
|
7
|
+
data.tar.gz: 8edfc4e9306562278265093c9c0a439c3e41560be52eee12859508257ca680a22ce2b276730752dd2c9bd5a8a6de0534ca25d7fba4d7c5846bad9f1d9a4aebfd
|
data/ext/nats/extconf.rb
ADDED
data/ext/nats/nats.c
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
#include <nats/nats.h>
|
2
|
+
#include <ruby.h>
|
3
|
+
|
4
|
+
typedef struct {
|
5
|
+
natsConnection *conn;
|
6
|
+
} Connection;
|
7
|
+
|
8
|
+
static void ruby_nats_destroy(void *self) {
|
9
|
+
((Connection*) self)->conn = NULL;
|
10
|
+
free(self);
|
11
|
+
}
|
12
|
+
|
13
|
+
static VALUE ruby_nats_create(VALUE klass) {
|
14
|
+
Connection *conn = malloc(sizeof(Connection));
|
15
|
+
return Data_Wrap_Struct(klass, NULL, ruby_nats_destroy, conn);
|
16
|
+
}
|
17
|
+
|
18
|
+
static VALUE ruby_nats_close(VALUE self) {
|
19
|
+
Connection *conn = NULL;
|
20
|
+
Data_Get_Struct(self, Connection, conn);
|
21
|
+
natsConnection_Destroy(conn->conn);
|
22
|
+
return self;
|
23
|
+
}
|
24
|
+
|
25
|
+
static VALUE ruby_nats_connect(VALUE self, VALUE uri) {
|
26
|
+
Connection *conn = NULL;
|
27
|
+
Data_Get_Struct(self, Connection, conn);
|
28
|
+
natsStatus s = natsConnection_Connect(&(conn->conn), NULL);
|
29
|
+
|
30
|
+
if (s != NATS_OK) {
|
31
|
+
rb_raise(rb_eException, natsStatus_GetText(s));
|
32
|
+
}
|
33
|
+
|
34
|
+
return self;
|
35
|
+
}
|
36
|
+
|
37
|
+
static VALUE ruby_nats_publish(VALUE self, VALUE subject, VALUE data) {
|
38
|
+
Connection *conn = NULL;
|
39
|
+
Data_Get_Struct(self, Connection, conn);
|
40
|
+
natsStatus s = natsConnection_PublishString(
|
41
|
+
conn->conn,
|
42
|
+
StringValuePtr(subject),
|
43
|
+
StringValuePtr(data));
|
44
|
+
|
45
|
+
// if (s == NATS_OK) {
|
46
|
+
// s = natsConnection_FlushTimeconn(conn->conn, 1000);
|
47
|
+
// s = natsConnection_Flush(nc);
|
48
|
+
// }
|
49
|
+
|
50
|
+
if (s != NATS_OK) {
|
51
|
+
rb_raise(rb_eException, natsStatus_GetText(s));
|
52
|
+
}
|
53
|
+
|
54
|
+
return self;
|
55
|
+
}
|
56
|
+
|
57
|
+
static VALUE ruby_nats_subscribe(VALUE self, VALUE subject, VALUE callback) {
|
58
|
+
Connection *conn = NULL;
|
59
|
+
Data_Get_Struct(self, Connection, conn);
|
60
|
+
rb_raise(rb_eException, "Not Implemented!");
|
61
|
+
return self;
|
62
|
+
}
|
63
|
+
|
64
|
+
static VALUE ruby_nats_subscribe_queuegroup(
|
65
|
+
VALUE self,
|
66
|
+
VALUE identifier,
|
67
|
+
VALUE subject,
|
68
|
+
VALUE callback) {
|
69
|
+
Connection *conn = NULL;
|
70
|
+
Data_Get_Struct(self, Connection, conn);
|
71
|
+
rb_raise(rb_eException, "Not Implemented!");
|
72
|
+
return self;
|
73
|
+
}
|
74
|
+
|
75
|
+
void Init_nats(void) {
|
76
|
+
VALUE cNatsModule = rb_define_module("NATS");
|
77
|
+
VALUE cNatsConnection = rb_define_class_under(cNatsModule, "Connection", rb_cObject);
|
78
|
+
rb_define_alloc_func(cNatsConnection, ruby_nats_create);
|
79
|
+
rb_define_method(cNatsConnection, "close", ruby_nats_close, 0);
|
80
|
+
rb_define_method(cNatsConnection, "connect", ruby_nats_connect, 1);
|
81
|
+
rb_define_method(cNatsConnection, "publish", ruby_nats_publish, 2);
|
82
|
+
rb_define_method(cNatsConnection, "subscribe", ruby_nats_subscribe, 2);
|
83
|
+
rb_define_method(cNatsConnection, "subscribe_qg", ruby_nats_subscribe_queuegroup, 3);
|
84
|
+
}
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nats-native
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.4.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ron Elliott
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake-compiler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
executables: []
|
30
|
+
extensions:
|
31
|
+
- ext/nats/extconf.rb
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ext/nats/nats.c
|
35
|
+
- ext/nats/extconf.rb
|
36
|
+
homepage:
|
37
|
+
licenses: []
|
38
|
+
metadata: {}
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 2.0.14.1
|
56
|
+
signing_key:
|
57
|
+
specification_version: 4
|
58
|
+
summary: NATS client for Ruby
|
59
|
+
test_files: []
|