private async ValueTask GetSchema(TopicName topicName, byte[] version) { var request = Commands.NewGetSchema(_requestId, topicName.ToString(), BytesSchemaVersion.Of(version)); var payload = new Payload(request, _requestId, "SendGetRawSchema"); var askResponse = await _clientCnx.Ask <AskResponse>(payload); if (askResponse.Failed) { _replyTo.Tell(askResponse); return; } var schemaResponse = askResponse.ConvertTo <Messages.GetSchemaResponse>(); var err = schemaResponse.Response.ErrorCode; if (err != ServerError.UnknownError) { var e = $"{err}: {schemaResponse.Response.ErrorMessage}"; _log.Error(e); _replyTo.Tell(new AskResponse(new PulsarClientException(new Exception(e)))); } else { var schema = schemaResponse.Response.Schema; var info = new SchemaInfo { Schema = schema.SchemaData, Name = schema.Name, Properties = schema.Properties.ToDictionary(k => k.Key, v => v.Value), Type = SchemaType.ValueOf((int)schema.type) }; _replyTo.Tell(new AskResponse(new GetSchemaInfoResponse(info))); } }
public static SchemaType GetSchemaTypeFor(SchemaType type) { if (type.Value < 0) { // this is unexpected return(SchemaType.NONE); } else { return(SchemaType.ValueOf(type.Value)); } }
public static SchemaType GetSchemaType(Proto.Schema.Type type) { if (type < 0) { // this is unexpected return(SchemaType.NONE); } else { return(SchemaType.ValueOf((int)type)); } }
private static ISchemaInfo DecodeSubSchemaInfo(ISchemaInfo parentSchemaInfo, string schemaNameProperty, string schemaTypeProperty, string schemaPropsProperty, byte[] schemaData) { var parentSchemaProps = parentSchemaInfo.Properties; var schemaName = parentSchemaProps.GetOrDefault(schemaNameProperty, ""); var schemaType = SchemaType.ValueOf(parentSchemaProps.GetOrDefault(schemaTypeProperty, SchemaType.BYTES.Name)); IDictionary <string, string> schemaProps; if (!parentSchemaProps.TryGetValue(schemaPropsProperty, out var schemaPropsStr)) { schemaProps = new Dictionary <string, string>(); } else { schemaProps = SchemaUtils.DeserializeSchemaProperties(schemaPropsStr); } return(new SchemaInfo { Name = schemaName, Type = schemaType, Schema = schemaData, Properties = schemaProps }); }