replication.rs

replication.rs - Топик с ответами на регистрацию подписки у поставщика

Позитивный ответ на запрос подписки на репликацию передается только в случае, если Витрина успешного обработала все выражения из параметра sql запроса. Один запрос - один ответ. Один ответ - одно сообщение.

Структура сообщения

subscriptionRegistrationResultMessage:
  description: Успешный ответ с результатом регистрации подписки у поставщика. Содержит сведения о структуре таблиц, необходимой для хранения реплик
  schemaFormat: 'application/vnd.apache.avro;version=1.9.0'
  bindings:
    kafka:
      key:
        type: string
        format: uuid
        description: Уникальный идентификатор подзапроса
  headers:
    type: object
    properties:
      AGENT_CONSUMER_ID:
        description: Идентификатор агента потребителя
        type: string
  payload:
    $ref: '#/components/schemas/subscriptionRegistrationResult'
  examples:
    - name: simple
      headers:
        AGENT_CONSUMER_ID: agent-fias
      payload:
        requestId: 2e8c8ab2-44db-4dcb-8ae5-2365121b4e14
        subRequestId:
          string: 00000000-0000-0000-0000-000000000000
        subscriptionId: dcf43fc7-e152-459b-8af5-48d91d4b6a21
        datamartMnemonic: fias
        lastSynId: 10
        snapshotKeySize: 1024
        deltaUuid: 79a928f5-eab5-49ea-a947-2c99fbf39b6e
        tables:
          - tableId: 90722850-b1c7-42eb-836c-b2f88849e22c
            tableName:
              string: tab
            sql: select * from v1_addrobj
            fields:
              - name: oktmo
                type: VARCHAR
                length: null
                precision: null
                scale: null
                primaryKey: null
                shardingKey: null
        tables:
          ru.rtlabs.common.replication.storage.ReplicationTableInfo:
            tableId:
              string: 00000000-0000-0000-0000-000000000000
            tableName:
              string: tab
            sql:
              string: select * from v1_addrobj
            fields:
              - name: oktmo
                type: VARCHAR
                length: null
                precision: null
                primaryKey: null
                scale: null
                shardingKey: null

Avro-схема сообщения

subscriptionRegistrationResult:
  schemaFormat: 'application/vnd.apache.avro;version=1.9.0'
  type: record
  name: SubscriptionRegistrationResult
  namespace: ru.rtlabs.common.replication.subscription
  fields:
    - name: requestId
      description: Уникальный идентификатор запроса
      type:
        type: string
        logicalType: uuid
    - name: subRequestId
      description: Уникальный идентификатор подзапроса,
      default: null
      type:
        - 'null'
        - type: string
          logicalType: uuid
    - name: subscriptionId
      description: Уникальный идентификатор подписки
      type:
        type: string
        logicalType: uuid
    - name: datamartMnemonic
      description: Мнемоника витрины-источника
      type: string
    - name: lastSynId
      description: Последний id дельты примененной в витрине на момент подписки (если дельт нет, то придет -1)
      type: int
    - name: tables
      description: Структура таблиц хранения реплик
      default: []
      type:
        type: array
        items:
          type: record
          name: ReplicationTableInfo
          namespace: ru.rtlabs.common.replication.storage
          fields:
            - name: tableId
              description: Идентификатор таблицы
              default: null
              type:
                - 'null'
                - type: string
                  logicalType: uuid
            - name: tableName
              description: Наименование таблицы
              type:
                - 'null'
                - type: string
            - name: sql
              description: sql, для которого должна быть создана таблица
              default: null
              type:
                - 'null'
                - type: string
            - name: fields
              description: Поля таблицы
              type:
                type: array
                items:
                  type: record
                  name: ReplicationFieldInfo
                  namespace: ru.rtlabs.common.replication.storage
                  description: Описание поля таблицы
                  fields:
                    - name: name
                      description: Имя поля
                      type: string
                    - name: type
                      description: Тип поля
                      type: string
                    - name: length
                      description: Максимальная длина строки, если пусто, то нет ограничений
                      type:
                        - int
                        - 'null'
                    - name: precision
                      description: Количество значимых цифр у decimal и numeric. Т.е. количество в целой части + количество в дробной части. Если пусто, то без размера
                      type:
                        - int
                        - 'null'
                    - name: scale
                      description: Масштаб decimal и numeric. Т.е. количество значимых цифр в дробной части. Если пусто, то нет дробной части
                      default: null
                      type:
                        - 'null'
                        - int
                    - name: primaryKey
                      description: Порядковый номер поля (начиная с 0) в составе первичного ключа. null - если не входит в состав первичного ключа
                      type:
                        - int
                        - 'null'
                    - name: shardingKey
                      description: Порядковый номер поля (начиная с 0) в составе ключа шардирования. null - если не входит в состав ключа шардирования
                      type:
                        - int
                        - 'null'