The service will connect to the Meetup Long-Polling RSVP stream (Meetup Long-Polling RSVP Stream) and stores the information acquired on a RDBMS database in MariaDb container (linuxserver/mariadb:latest). For information about the database schema, please go to section 7.
The below function will return an integer with the size in bytes of a stream chunk.
get_chunk_size()Get the size of a complete event from the stream.
:param: none
:return: int length of a complete event, in bytes
Return a chunk from the stream of chunk_size bytes.
get_chunk_data(chunk_size)Get the 'chunk_size' bytes from the stream
:param: chunk_size: http stream data
:return: str: return a chunk from the stream of chunk_size bytes
The below is a generator function, yielding rsvp events from the stream, as formatted JSON strings.
iter_listen():param: none
:return: json string
When invoked, this function will start collecting data from the RSVP stream, will filter the portion of data of interest, and make it persistent on the meetup->cities table.
listen():param: none
This function will drop the cities table (if exists), and create a new empty table.
create_table():param: none
Within this function we setup the filter in use by the listen() function. It will take the rsvp event JSON string, and return a JSON string subset of that data.
filter_data(data):param: json string
:return: json string
CREATE TABLE `cities` (
`idx` int(11) NOT NULL AUTO_INCREMENT,
`city` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`lat` float(5,2) DEFAULT NULL,
`lon` float(5,2) DEFAULT NULL,
`date` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`eid` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`gid` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`mid` varchar(255) COLLATE utf8_bin DEFAULT NULL,
PRIMARY KEY (`idx`)
) ENGINE=InnoDB AUTO_INCREMENT=47322 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
The code has passed static code analisys with pylint (PEP8) with 10/10 score.