Skip to content

yeti-switch/yeti-pg-ext

Repository files navigation

Build Status Made in Ukraine

Stand With Ukraine

yeti-pg-ext

yeti-pg-ext is a part of project Yeti

Build & Installation

Debian

Installation via Package (Debian 12/bookworm)

# apt install curl gnupg

# echo "deb [arch=amd64] http://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" > /etc/apt/sources.list.d/pgdg.list
# curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg

# echo "deb [arch=amd64] http://pkg.yeti-switch.org/debian/bookworm 1.13 main" > /etc/apt/sources.list.d/yeti.list
# curl https://pkg.yeti-switch.org/key.gpg | gpg --dearmor > /etc/apt/trusted.gpg.d/pkg.yeti-switch.org.gpg

# apt update
# apt install postgresql-16-yeti

Building from sources (Debian 12+)

get sources

$ git clone https://github.com/yeti-switch/yeti-pg-ext.git
$ cd yeti-pg-ext
$ make deb

install build dependencies

# echo "deb [arch=amd64] http://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" > /etc/apt/sources.list.d/pgdg.list
# curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg
# apt update
# apt build-dep .

build package

$ make deb

Building for Darwin (for web interface testing purposes only)

install build dependencies

# brew install postgresql nanomsg

get sources & build & install

$ git clone https://github.com/yeti-switch/yeti-pg-ext.git
$ cd yeti-pg-ext
$ make
# make install

add extension in postgresql

create extension

yeti=# CREATE SCHEMA yeti_ext;
CREATE SCHEMA

yeti=# CREATE EXTENSION yeti WITH SCHEMA yeti_ext;
CREATE EXTENSION

yeti=# \dx yeti
                 List of installed extensions
 Name | Version |  Schema  |            Description
------+---------+----------+-----------------------------------
 yeti | 1.3.9   | yeti_ext | helper functions for YETI project
(1 row)

yeti=# \df yeti_ext.*
                                                                                     List of functions
  Schema  |             Name              |        Result data type        |                                          Argument data types                                          |  Type
----------+-------------------------------+--------------------------------+-------------------------------------------------------------------------------------------------------+--------
 yeti_ext | lnp_endpoints_cache_set       | void                           | key text, response text, error boolean                                                                | func
 yeti_ext | lnp_endpoints_set             | void                           | endpoints text[]                                                                                      | func
 yeti_ext | lnp_endpoints_show            | SETOF yeti_ext.endpoints       |                                                                                                       | func
 yeti_ext | lnp_resolve_cnam              | json                           | database_id integer, data json                                                                        | func
 yeti_ext | lnp_resolve_tagged            | yeti_ext.lnp_result            | database_id integer, local_number text                                                                | func
 yeti_ext | lnp_resolve_tagged_with_error | yeti_ext.lnp_result_with_error | database_id integer, local_number text                                                                | func
 yeti_ext | lnp_set_rtt_timeout           | void                           | timeout_msec integer                                                                                  | func
 yeti_ext | lnp_set_timeout               | void                           | timeout_msec integer                                                                                  | func
 yeti_ext | rank_dns_srv                  | integer                        | weight integer                                                                                        | window
 yeti_ext | regexp_replace_rand           | text                           | text_in text, regexp_rule text, regexp_result text, keep_empty boolean DEFAULT false                  | func
 yeti_ext | regexp_replace_rand           | text[]                         | text_in text[], regexp_rule text, regexp_result text, keep_empty boolean DEFAULT false                | func
 yeti_ext | regexp_replace_rand           | text                           | text_in text, regexp_rule text, regexp_result text, regexp_opt text, keep_empty boolean DEFAULT false | func
 yeti_ext | replace_rand                  | text                           | text                                                                                                  | func
 yeti_ext | tag_action                    | integer[]                      | op integer, a integer[], b integer[]                                                                  | func
 yeti_ext | tag_compare                   | integer                        | a integer[], b integer[], match_mode smallint DEFAULT 0                                               | func
 yeti_ext | tbf_rate_check                | boolean                        | namespace_id integer, bucket_id bigint, rate real                                                     | func
(16 rows)

add extension to the shared_preload_libraries to use tbf_rate_check() function (needs postgresql restart)

# grep yeti /etc/postgresql/16/main/postgresql.conf
shared_preload_libraries='yeti_pg_ext'

# pg_ctlcluster 16 main restart