You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Enables/disables the library debug output (including errors logging).
59
59
// Disabled by default.
@@ -717,6 +717,7 @@ class AWSKinesisStreams.Record {
717
717
_error =null;
718
718
_explicitHashKey =null;
719
719
_prevSequenceNumber =null;
720
+
_encoder =null;
720
721
721
722
// Creates and returns AWSKinesisStreams.Record object that can be written into an
722
723
// Amazon Kinesis stream using AWSKinesisStreams.Producer methods.
@@ -733,15 +734,19 @@ class AWSKinesisStreams.Record {
733
734
// prevSequenceNumber : See http://docs.aws.amazon.com/kinesis/latest/APIReference/API_PutRecord.html#Streams-PutRecord-request-SequenceNumberForOrdering
734
735
// string (optional)
735
736
//
737
+
// encoder : a custom JSON encoder function for encoding the provided data (e.g. [JSONEncoder.encode](https://github.com/electricimp/JSONEncoder))
738
+
// function (otpional)
739
+
//
736
740
// Returns: AWSKinesisStreams.Record object that can be
Copy file name to clipboardExpand all lines: README.md
+26-5
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ The AWSKinesisStreams library utilizes the [AWSRequestV4](https://github.com/ele
13
13
14
14
```squirrel
15
15
#require "AWSRequestV4.class.nut:1.0.2"
16
-
#require "AWSKinesisStreams.agent.lib.nut:1.0.0"
16
+
#require "AWSKinesisStreams.agent.lib.nut:1.1.0"
17
17
```
18
18
19
19
## Library Usage ##
@@ -68,7 +68,7 @@ This class represents an AWS Kinesis Streams record: a combination of data attri
68
68
|*timestamp*| Integer | The approximate time that the record was inserted into the stream. In number of seconds since Unix epoch (midnight, 1 Jan 1970) |
69
69
|*encryptionType*|[AWS_KINESIS_STREAMS_ENCRYPTION_TYPE](#aws_kinesis_streams_encryption_type-enum)| The encryption type used on the record |
This method creates and returns an AWSKinesisStreams.Record object that can be written into an Amazon Kinesis stream using [AWSKinesisStreams.Producer](#awskinesisstreamsproducer-class) methods.
74
74
@@ -78,6 +78,7 @@ This method creates and returns an AWSKinesisStreams.Record object that can be w
78
78
|*partitionKey*| String | Yes | Identifies which shard in the stream the data record is assigned to (see the [Kinesis Streams documentation](http://docs.aws.amazon.com/kinesis/latest/APIReference/API_Record.html#Streams-Type-Record-PartitionKey)) |
79
79
|*explicitHashKey*| String | Optional | The hash value used to explicitly determine the shard the data record is assigned to by overriding the partition key hash (see the [Kinesis Streams documentation](http://docs.aws.amazon.com/kinesis/latest/APIReference/API_PutRecord.html#Streams-PutRecord-request-ExplicitHashKey)) |
80
80
|*prevSequenceNumber*| String | Optional | See the [Kinesis Streams documentation](http://docs.aws.amazon.com/kinesis/latest/APIReference/API_PutRecord.html#Streams-PutRecord-request-SequenceNumberForOrdering)|
81
+
|*encoder*| Function | Optional | A custom JSON encoder function for encoding the provided data (e.g. [JSONEncoder.encode](https://github.com/electricimp/JSONEncoder)) |
81
82
82
83
## AWS_KINESIS_STREAMS_ENCRYPTION_TYPE Enum ##
83
84
@@ -268,7 +269,26 @@ A type of Squirrel data which can be encoded/decoded into/from JSON, eg. table,
268
269
269
270
```squirrel
270
271
#require "AWSRequestV4.class.nut:1.0.2"
271
-
#require "AWSKinesisStreams.agent.lib.nut:1.0.0"
272
+
#require "AWSKinesisStreams.agent.lib.nut:1.1.0"
273
+
#require "JSONEncoder.class.nut:2.0.0"
274
+
275
+
//This class can be used to hold numbers larger than Squirrel can natively support (i.e. anything larger than 32-bit)
276
+
//and then be encoded as a number (rather than a string) when encoded with `JSONEncoder.encode`.
277
+
class JSONLiteralString {
278
+
_string = null;
279
+
280
+
constructor (string) {
281
+
_string = string.tostring();
282
+
}
283
+
284
+
function _serializeRaw() {
285
+
return _string;
286
+
}
287
+
288
+
function toString() {
289
+
return _string;
290
+
}
291
+
}
272
292
273
293
// Substitute with real values
274
294
const AWS_KINESIS_REGION = "<YOUR_AWS_REGION>";
@@ -292,7 +312,8 @@ producer.putRecord(AWSKinesisStreams.Record("Hello!", "partitionKey"), function
AWSKinesisStreams.Record({ "a" : JSONLiteralString("123456789123456789") }, "partitionKey4", null, null, JSONEncoder.encode.bindenv(JSONEncoder)) //write record using custom encoder
296
317
];
297
318
298
319
producer.putRecords(records, function (error, failedRecordCount, putResults) {
@@ -315,7 +336,7 @@ producer.putRecords(records, function (error, failedRecordCount, putResults) {
0 commit comments