Skip to content

Commit bac2fb9

Browse files
authored
Merge branch 'v1_develop' into v1_tmp_develop
2 parents f054efa + 354f77b commit bac2fb9

2 files changed

Lines changed: 124 additions & 27 deletions

File tree

.github/workflows/main-dev-deploy.yml

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,37 +27,38 @@ jobs:
2727
uses: ./.github/workflows/reusable-build-and-publish.yml
2828

2929

30-
30+
### NOTE - Disabled for Dev branch
3131
### Job to Release CodeDeploy artifact to S3 bucket
3232
# Output
3333
# - s3-artifact-path = s3 bucket artifact path to be used for codedeploy (e.g. 1.1.1/deployment.tar.gz)
34-
S3-CodeDeploy-Release:
35-
needs: Build-and-Publish
36-
uses: ./.github/workflows/reusable-s3-codedeploy-release.yml
37-
with:
38-
aws-region: ${{ vars.AWS_REGION }}
39-
pipeline-artifact-name: ${{ needs.Build-and-Publish.outputs.pipeline-artifact-name }}
40-
s3-bucket-name: ${{ vars.RELEASE_S3_BUCKET_NAME }}
41-
s3-bucket-dir-path: ${{ needs.Build-and-Publish.outputs.app-version }}
42-
s3-artifact-version: ${{ needs.Build-and-Publish.outputs.codedeploy-artifact-version }}
43-
secrets:
44-
aws-key: ${{ secrets.AWS_KEY }}
45-
aws-secret: ${{ secrets.AWS_SECRET }}
34+
#S3-CodeDeploy-Release:
35+
# needs: Build-and-Publish
36+
# uses: ./.github/workflows/reusable-s3-codedeploy-release.yml
37+
# with:
38+
# aws-region: ${{ vars.AWS_REGION }}
39+
# pipeline-artifact-name: ${{ needs.Build-and-Publish.outputs.pipeline-artifact-name }}
40+
# s3-bucket-name: ${{ vars.RELEASE_S3_BUCKET_NAME }}
41+
# s3-bucket-dir-path: ${{ needs.Build-and-Publish.outputs.app-version }}
42+
# s3-artifact-version: ${{ needs.Build-and-Publish.outputs.codedeploy-artifact-version }}
43+
# secrets:
44+
# aws-key: ${{ secrets.AWS_KEY }}
45+
# aws-secret: ${{ secrets.AWS_SECRET }}
4646

4747

4848

49+
### NOTE - Disabled for Dev branch
4950
### Job to Deploy CodeDeploy artifact to Dev environment
50-
Dev-Deploy:
51-
needs: S3-CodeDeploy-Release
52-
uses: ./.github/workflows/reusable-codedeploy-deployment.yml
53-
with:
54-
aws-region: ${{ vars.AWS_REGION }}
55-
codedeploy-app-name: ${{ vars.CODEDEPLOY_APP_NAME }}
56-
codedeploy-group-name: ${{ vars.CODEDEPLOY_DEV_GROUP_NAME }}
57-
deployment-description: 'Deployment triggered by ${{ github.triggering_actor }} from Github repo [${{ github.repository }}], ${{ github.ref_type }} [${{ github.ref_name }}], commit sha [${{ github.sha }}]'
58-
s3-bucket-name: ${{ vars.RELEASE_S3_BUCKET_NAME }}
59-
s3-artifact-path: ${{ needs.S3-CodeDeploy-Release.outputs.s3-artifact-path }}
60-
s3-artifact-type: tgz
61-
secrets:
62-
aws-key: ${{ secrets.AWS_KEY }}
63-
aws-secret: ${{ secrets.AWS_SECRET }}
51+
#Dev-Deploy:
52+
# needs: S3-CodeDeploy-Release
53+
# uses: ./.github/workflows/reusable-codedeploy-deployment.yml
54+
# with:
55+
# aws-region: ${{ vars.AWS_REGION }}
56+
# codedeploy-app-name: ${{ vars.CODEDEPLOY_APP_NAME }}
57+
# codedeploy-group-name: ${{ vars.CODEDEPLOY_DEV_GROUP_NAME }}
58+
# deployment-description: 'Deployment triggered by ${{ github.triggering_actor }} from Github repo [${{ github.repository }}], ${{ github.ref_type }} [${{ github.ref_name }}], commit sha [${{ github.sha }}]'
59+
# s3-bucket-name: ${{ vars.RELEASE_S3_BUCKET_NAME }}
60+
# s3-artifact-path: ${{ needs.S3-CodeDeploy-Release.outputs.s3-artifact-path }}
61+
# s3-artifact-type: tgz
62+
# secrets:
63+
# aws-key: ${{ secrets.AWS_KEY }}
64+
# aws-secret: ${{ secrets.AWS_SECRET }}

xyz-psql-connector/src/main/resources/naksha_ext.sql

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,102 @@ BEGIN
563563
END
564564
$BODY$;
565565

566+
-- Custom after trigger script for very special scenario where transaction entries (and so SNS event publishing) is to be skipped
567+
-- for special DMLs.
568+
CREATE OR REPLACE FUNCTION xyz_config.naksha_space_after_trigger_to_skip_txn()
569+
RETURNS trigger
570+
LANGUAGE 'plpgsql' VOLATILE
571+
AS $BODY$
572+
DECLARE
573+
author text;
574+
app_id text;
575+
new_uuid uuid;
576+
txn uuid;
577+
ts_millis int8;
578+
rts_millis int8;
579+
i int8;
580+
xyz jsonb;
581+
newMarkerPresent bool;
582+
oldMarkerPresent bool;
583+
disable_txn bool;
584+
585+
BEGIN
586+
------------------------------------------------------
587+
-- Use of this custom script is to support skipping transaction entries (thereby indirectly disabling SNS event publish),
588+
-- for special DMLs. It is disabled for those DML operations where either of the following criteria is true:
589+
--
590+
-- 1) Postgres config parameter "naksha_config.skip_txn" is found to be "true"
591+
-- 2) If NEW JSON Feature has xyz.tags with value "disable_event_publish", but OLD JSON Feature doesn't.
592+
-- No OLD entry is considered to be absence of tag.
593+
-- Check for OLD entry is to ensure event suppression happens only once for that "special" DML and not for subsequent "genuine" DMLs.
594+
--
595+
-- This is applicable across INSERT/UPDATE/DELETE operation.
596+
-- Transaction entry is skipped, but History entry is still made.
597+
-- If condition (1) is satisfied, then condition (2) is not checked.
598+
------------------------------------------------------
599+
600+
xyz := OLD.jsondata->'properties'->'@ns:com:here:xyz';
601+
602+
disable_txn := FALSE;
603+
-- Disable Txn INSERT if session level flag 'naksha_config.skip_txn' is 'true'
604+
IF coalesce(current_setting('naksha_config.skip_txn', true), '') = 'true' THEN
605+
disable_txn := TRUE;
606+
END IF;
607+
-- (one more check - if it was inconclusive)
608+
-- Disable Txn INSERT if NEW tags has marker 'disable_event_publish' BUT OLD tags has not
609+
IF (NOT disable_txn) THEN
610+
oldMarkerPresent := coalesce(xyz->'tags' ? 'disable_event_publish', false);
611+
newMarkerPresent := coalesce(NEW.jsondata->'properties'->'@ns:com:here:xyz'->'tags' ? 'disable_event_publish', false);
612+
disable_txn := (NOT oldMarkerPresent AND newMarkerPresent);
613+
END IF;
614+
615+
616+
IF (disable_txn) THEN
617+
PERFORM xyz_config.naksha_tx_custom_insert(TG_TABLE_SCHEMA, TG_TABLE_NAME);
618+
ELSE
619+
PERFORM xyz_config.naksha_tx_insert(TG_TABLE_SCHEMA, TG_TABLE_NAME);
620+
END IF;
621+
622+
623+
IF TG_OP = 'INSERT' OR TG_OP = 'UPDATE' THEN
624+
EXECUTE format('INSERT INTO %s."%s_hst" (jsondata,geo,i) VALUES(%L,%L,%L)',
625+
TG_TABLE_SCHEMA, TG_TABLE_NAME,
626+
NEW.jsondata, NEW.geo, NEW.i);
627+
RETURN NEW;
628+
END IF;
629+
630+
rts_millis := xyz_config.naksha_ts_millis(clock_timestamp());
631+
ts_millis := xyz_config.naksha_ts_millis(current_timestamp);
632+
txn := xyz_config.naksha_tx_current();
633+
i = nextval('"'||TG_TABLE_SCHEMA||'"."'||TG_TABLE_NAME||'_i_seq"');
634+
new_uuid := xyz_config.naksha_uuid_feature_number(i, current_timestamp);
635+
author := xyz_config.naksha_tx_get_author(OLD.jsondata);
636+
app_id := xyz_config.naksha_tx_get_app_id();
637+
638+
-- We do these updates, because in the "after-trigger" we only write into history.
639+
IF xyz IS NULL THEN
640+
xyz := '{}'::jsonb;
641+
END IF;
642+
xyz := jsonb_set(xyz, '{"action"}', ('"DELETE"')::jsonb, true);
643+
xyz := jsonb_set(xyz, '{"version"}', coalesce((''||(xyz_config.naksha_json_version(OLD.jsondata)+1::int8)),'1')::jsonb, true);
644+
xyz := jsonb_set(xyz, '{"author"}', coalesce(author, 'null')::jsonb, true);
645+
xyz := jsonb_set(xyz, '{"appId"}', coalesce(app_id, 'null')::jsonb, true);
646+
xyz := jsonb_set(xyz, '{"puuid"}', xyz->'uuid', true);
647+
xyz := jsonb_set(xyz, '{"uuid"}', ('"'||((new_uuid)::text)||'"')::jsonb, true);
648+
xyz := jsonb_set(xyz, '{"txn"}', ('"'||((txn)::text)||'"')::jsonb, true);
649+
-- createdAt and rtcts stay what they are
650+
xyz := jsonb_set(xyz, '{"updatedAt"}', (ts_millis::text)::jsonb, true);
651+
xyz := jsonb_set(xyz, '{"rtuts"}', (rts_millis::text)::jsonb, true);
652+
OLD.jsondata = jsonb_set(OLD.jsondata, '{"properties","@ns:com:here:xyz"}', xyz, true);
653+
OLD.i = i;
654+
EXECUTE format('INSERT INTO %s."%s_hst" (jsondata,geo,i) VALUES(%L,%L,%L)',
655+
TG_TABLE_SCHEMA, TG_TABLE_NAME,
656+
OLD.jsondata, OLD.geo, OLD.i);
657+
RETURN OLD;
658+
END
659+
$BODY$
660+
;
661+
566662
-- Ensures that the given schema and table exist as storage location for a space.
567663
CREATE OR REPLACE FUNCTION xyz_config.naksha_space_ensure(_schema text, _table text)
568664
RETURNS void

0 commit comments

Comments
 (0)