protected override async Task <int> OnExecute(CommandLineApplication app) { //Topic = "cc_payments"; //Key = false; if (SchemaId.HasValue) { var schema = await SchemaRegistryClient.GetSchemaAsync(SchemaId.Value); Output($"SCHM: {schema}"); return(1); } else { if (string.IsNullOrEmpty(Topic)) { return(-1); } var schemaName = Key ? SchemaRegistryClient.ConstructKeySubjectName(Topic) : SchemaRegistryClient.ConstructValueSubjectName(Topic); var schema = await SchemaRegistryClient.GetLatestSchemaAsync(schemaName); var header = $"Subject: {schema.Subject} | ID: {schema.Id} | Version: {schema.Version}"; Output($"INFO: {header}"); Output($"SCHM: {schema.SchemaString}"); return(1); } }
private async Task <Schema> GetSchemaByIdAsync(string schemaId, CancellationToken cancellationToken) { if (_cachedSchemas.TryGetValue(schemaId, out var cachedSchema)) { return(cachedSchema); } var schemaContent = (await _client.GetSchemaAsync(schemaId, cancellationToken).ConfigureAwait(false)).Value.Content; var schema = Schema.Parse(schemaContent); _cachedSchemas.Add(schemaId, schema); return(schema); }