如何在融合模式注册表中演化模式

时间:2020-04-29 19:44:58

标签: avro confluent-schema-registry

我正在使用Avro / Kafka和Confluent的Schema Registry for Avro。

我使用avsc文件和avdl制作了一些具有基本类型的基本架构和主题。

我正在查看Confluent编写的API文档,以尝试将Schema升级到版本2。特别是这一部分:

https://docs.confluent.io/current/schema-registry/using.html#register-a-new-version-of-a-schema-under-the-subject-kafka-key

但是当我尝试发布到该端点时,我得到了422 Conflict

我正在使用BACKWARDS兼容性,并且仅更新了先前版本中的一个字段:

{
    "type": "record",
    "name": "Address",
    "fields": [
        {"name": "id", "type": "string"},
        {"name": "street", "type": "string"}
    ]
}

以及新版本:

{
    "type": "record",
    "name": "Address",
    "fields": [
        {"name": "id", "type": "string"},
        {"name": "street", "type": "string"},
        {"name": "number", "type": "int"}
    ]
}

谁能告诉我如何发展模式?

1 个答案:

答案 0 :(得分:0)

通过设置

解决了
clang::Lexer::getSourceText

我以前设置为允许/** * Gets the portion of the code that corresponds to given SourceRange, including the * last token. Returns expanded macros. * * @see get_source_text_raw() */ std::string get_source_text(clang::SourceRange range, const clang::SourceManager& sm) { clang::LangOptions lo; // NOTE: sm.getSpellingLoc() used in case the range corresponds to a macro/preprocessed source. auto start_loc = sm.getSpellingLoc(range.getBegin()); auto last_token_loc = sm.getSpellingLoc(range.getEnd()); auto end_loc = clang::Lexer::getLocForEndOfToken(last_token_loc, 0, sm, lo); auto printable_range = clang::SourceRange{start_loc, end_loc}; return get_source_text_raw(printable_range, sm); } /** * Gets the portion of the code that corresponds to given SourceRange exactly as * the range is given. * * @warning The end location of the SourceRange returned by some Clang functions * (such as clang::Expr::getSourceRange) might actually point to the first character * (the "location") of the last token of the expression, rather than the character * past-the-end of the expression like clang::Lexer::getSourceText expects. * get_source_text_raw() does not take this into account. Use get_source_text() * instead if you want to get the source text including the last token. * * @warning This function does not obtain the source of a macro/preprocessor expansion. * Use get_source_text() for that. */ std::string get_source_text_raw(clang::SourceRange range, const clang::SourceManager& sm) { return clang::Lexer::getSourceText(clang::CharSourceRange::getCharRange(range), sm, clang::LangOptions()); } access.control.allow.methods=GET,POST,OPTIONS,PUT,DELETE ,但似乎只允许GET(?),所以在更改此属性后,我可以更改/发展模式。