Skip to content

Commit

Permalink
Prepare for release 2.1 (#1017)
Browse files Browse the repository at this point in the history
* Add CHANGELOG entry for the release
* Update version number throughout
* Update vendored source dependency for parson
* Update vendored Postgres sources snprintf, strerror
* Update version related tests
  • Loading branch information
gkokolatos authored Nov 24, 2023
1 parent 18a8650 commit 2fda3e0
Show file tree
Hide file tree
Showing 21 changed files with 423 additions and 121 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
### pg_auto_failover v2.1 (November 24, 2022) ###

This release incorporates support for Postgres major version 16, some bug fixes,
documentation updates, and usual code maintenance work.

### Added
* Support for Postgres major version 16. (#1013, #1006, )
* Improve on documentation, Docker images, and tutorials. (#964, #954, #947)
* PGDATABASE as default create node --dbname. (#956)
* Add chapters to the documentation navigation. (#954)

### Fixed
* Makefile .PHONY target is defined throughout where needed. (#1008)
* History file parsing allowing for files longer than 1024 lines. (#995)
* A mistake in setup description (#984)
* Typo in pg_autoctl_do_pgsetup.rst (#961)
* pg_autoctl version Postgres compatibility string. (#951)
* Creating the PGUSER at pg_autoctl create postgres time. (#950)
* Dockerfile compatibility for Citus before 11. (#946)
* Punctuation in README.md. (#945)

### Changed
* Main Makefile is reorganized to split out citus and azure specifics. (#1008)
* Citus version matrix with new Citus releases. (#990)
* Update Citus from 11.1.2 to 11.1.3 in the build system. (#957)

### pg_auto_failover v2.0 (October 7, 2022) ###

This new release includes support for Citus in pg_auto_failover, the usual
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ def __init__(self, **options):
# built documents.
#
# The short X.Y version.
version = "2.0"
version = "2.1"
# The full version, including alpha/beta/rc tags.
release = "2.0"
release = "2.1"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
9 changes: 7 additions & 2 deletions src/bin/lib/parson/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.DS_Store
test
*.o
testcpp
testcpp.*
test.dSYM
tests/test_2_serialized.txt
tests/test_2_serialized_pretty.txt
test_hash_collisions
build/**
29 changes: 29 additions & 0 deletions src/bin/lib/parson/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.5)
project(parson C)

include (GNUInstallDirs)

set(PARSON_VERSION 1.5.3)
add_library(parson parson.c)
target_include_directories(parson PUBLIC $<INSTALL_INTERFACE:include>)

set_target_properties(parson PROPERTIES PUBLIC_HEADER "parson.h")
set_target_properties(parson PROPERTIES VERSION ${PARSON_VERSION})
set_target_properties(parson PROPERTIES SOVERSION ${PARSON_VERSION})

install(
TARGETS parson
EXPORT parsonTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT shlib
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(
EXPORT parsonTargets
FILE parsonConfig.cmake
NAMESPACE parson::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)

149 changes: 149 additions & 0 deletions src/bin/lib/parson/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
## About
Parson is a lightweight [json](http://json.org) library written in C.

## Features
* Lightweight (only 2 files)
* Simple API
* Addressing json values with dot notation (similar to C structs or objects in most OO languages, e.g. "objectA.objectB.value")
* C89 compatible
* Test suites

## Installation
Run:
```
git clone https://github.com/kgabis/parson.git
```
and copy parson.h and parson.c to you source code tree.

Run ```make test``` to compile and run tests.

## Examples
### Parsing JSON
Here is a function, which prints basic commit info (date, sha and author) from a github repository.
```c
void print_commits_info(const char *username, const char *repo) {
JSON_Value *root_value;
JSON_Array *commits;
JSON_Object *commit;
size_t i;

char curl_command[512];
char cleanup_command[256];
char output_filename[] = "commits.json";

/* it ain't pretty, but it's not a libcurl tutorial */
sprintf(curl_command,
"curl -s \"https://api.github.com/repos/%s/%s/commits\" > %s",
username, repo, output_filename);
sprintf(cleanup_command, "rm -f %s", output_filename);
system(curl_command);

/* parsing json and validating output */
root_value = json_parse_file(output_filename);
if (json_value_get_type(root_value) != JSONArray) {
system(cleanup_command);
return;
}

/* getting array from root value and printing commit info */
commits = json_value_get_array(root_value);
printf("%-10.10s %-10.10s %s\n", "Date", "SHA", "Author");
for (i = 0; i < json_array_get_count(commits); i++) {
commit = json_array_get_object(commits, i);
printf("%.10s %.10s %s\n",
json_object_dotget_string(commit, "commit.author.date"),
json_object_get_string(commit, "sha"),
json_object_dotget_string(commit, "commit.author.name"));
}

/* cleanup code */
json_value_free(root_value);
system(cleanup_command);
}

```
Calling ```print_commits_info("torvalds", "linux");``` prints:
```
Date SHA Author
2012-10-15 dd8e8c4a2c David Rientjes
2012-10-15 3ce9e53e78 Michal Marek
2012-10-14 29bb4cc5e0 Randy Dunlap
2012-10-15 325adeb55e Ralf Baechle
2012-10-14 68687c842c Russell King
2012-10-14 ddffeb8c4d Linus Torvalds
...
```
### Persistence
In this example I'm using parson to save user information to a file and then load it and validate later.
```c
void persistence_example(void) {
JSON_Value *schema = json_parse_string("{\"name\":\"\"}");
JSON_Value *user_data = json_parse_file("user_data.json");
char buf[256];
const char *name = NULL;
if (user_data == NULL || json_validate(schema, user_data) != JSONSuccess) {
puts("Enter your name:");
scanf("%s", buf);
user_data = json_value_init_object();
json_object_set_string(json_object(user_data), "name", buf);
json_serialize_to_file(user_data, "user_data.json");
}
name = json_object_get_string(json_object(user_data), "name");
printf("Hello, %s.", name);
json_value_free(schema);
json_value_free(user_data);
return;
}
```

### Serialization
Creating JSON values is very simple thanks to the dot notation.
Object hierarchy is automatically created when addressing specific fields.
In the following example I create a simple JSON value containing basic information about a person.
```c
void serialization_example(void) {
JSON_Value *root_value = json_value_init_object();
JSON_Object *root_object = json_value_get_object(root_value);
char *serialized_string = NULL;
json_object_set_string(root_object, "name", "John Smith");
json_object_set_number(root_object, "age", 25);
json_object_dotset_string(root_object, "address.city", "Cupertino");
json_object_dotset_value(root_object, "contact.emails", json_parse_string("[\"[email protected]\",\"[email protected]\"]"));
serialized_string = json_serialize_to_string_pretty(root_value);
puts(serialized_string);
json_free_serialized_string(serialized_string);
json_value_free(root_value);
}

```
Output:
```
{
"name": "John Smith",
"age": 25,
"address": {
"city": "Cupertino"
},
"contact": {
"emails": [
"[email protected]",
"[email protected]"
]
}
}
```
## Contributing
I will always merge *working* bug fixes. However, if you want to add something new to the API, please create an "issue" on github for this first so we can discuss if it should end up in the library before you start implementing it.
Remember to follow parson's code style and write appropriate tests.
## My other projects
* [ape](https://github.com/kgabis/ape) - simple programming language implemented in C library
* [kgflags](https://github.com/kgabis/kgflags) - easy to use command-line flag parsing library
* [agnes](https://github.com/kgabis/agnes) - header-only NES emulation library
## License
[The MIT License (MIT)](http://opensource.org/licenses/mit-license.php)
36 changes: 36 additions & 0 deletions src/bin/lib/parson/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
project('parson', 'c',
version : '1.5.3',
license : 'MIT',
meson_version : '>=0.46.0',
default_options : [
'c_std=c89', 'optimization=2',
'warning_level=2'
]
)

parson_sources = ['parson.c']

parson_inc = include_directories('.')

parson_lib = library(
meson.project_name(),
sources: parson_sources,
install: true
)

install_headers('parson.h')

parson = declare_dependency(
include_directories : parson_inc,
link_with : parson_lib
)

pkgconfig = import('pkgconfig')

# will create a pkg config
pkgconfig.generate(parson_lib,
version: meson.project_version(),
filebase: meson.project_name(),
name: meson.project_name(),
description: 'Lightweight JSON library written in C.',
)
12 changes: 12 additions & 0 deletions src/bin/lib/parson/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "parson",
"version": "1.5.3",
"repo": "kgabis/parson",
"description": "Small json parser and reader",
"keywords": [ "json", "parser" ],
"license": "MIT",
"src": [
"parson.c",
"parson.h"
]
}
Loading

0 comments on commit 2fda3e0

Please sign in to comment.