Example #1
0
        /// <summary>
        /// Returns a new instance that otherwise is a copy of the original one, and
        /// optionally clones also the original schema it was associated with, if any.
        /// </summary>
        /// <param name="cloneSchema">True to also clone the schema this instance is associated
        /// with.</param>
        /// <returns>A new instance.</returns>
        public Record Clone(bool cloneSchema)
        {
            if (IsDisposed)
            {
                throw new ObjectDisposedException(this.ToString());
            }

            var cloned = _Schema == null
                                ? new Record(_Values.Length)
                                : new Record(cloneSchema ? _Schema.Clone() : _Schema);

            OnClone(cloned); return(cloned);
        }
Example #2
0
        private async ValueTask <ISchema <T> > PreProcessSchemaBeforeSubscribe <T>(ISchema <T> schema, string topicName)
        {
            if (schema != null && schema.SupportSchemaVersioning())
            {
                ISchemaInfoProvider schemaInfoProvider;
                try
                {
                    schemaInfoProvider = _schemaProviderLoadingCache.Get(topicName);
                    if (schemaInfoProvider == null)
                    {
                        _schemaProviderLoadingCache.Put(topicName, NewSchemaProvider(topicName));
                        schemaInfoProvider = _schemaProviderLoadingCache.Get(topicName);
                    }
                }
                catch (Exception e)
                {
                    _log.Error($"Failed to load schema info provider for topic {topicName}: {e}");
                    throw e;
                }
                schema = schema.Clone();
                if (schema.RequireFetchingSchemaInfo())
                {
                    var finalSchema = schema;
                    var schemaInfo  = await schemaInfoProvider.LatestSchema().ConfigureAwait(false);

                    if (null == schemaInfo)
                    {
                        if (!(finalSchema is AutoConsumeSchema))
                        {
                            throw new PulsarClientException.NotFoundException("No latest schema found for topic " + topicName);
                        }
                    }
                    _log.Info($"Configuring schema for topic {topicName} : {schemaInfo}");
                    finalSchema.ConfigureSchemaInfo(topicName, "topic", schemaInfo);
                    finalSchema.SchemaInfoProvider = schemaInfoProvider;
                    return(finalSchema);
                }
                else
                {
                    schema.SchemaInfoProvider = schemaInfoProvider;
                }
            }
            return(schema);
        }
Example #3
0
 public ISchema <byte[]> Clone()
 {
     return(new AutoProduceBytesSchema <byte[]>((ISchema <byte[]>)_schema.Clone()));
 }
		/// <summary>
		/// Factory method to create an empty record to return.
		/// </summary>
		protected virtual IRecord CreateEmptyRecord(ISchema schema)
		{
			return new Concrete.Record(schema.Clone());
		}
Example #5
0
 /// <summary>
 /// Factory method to create an empty record to return.
 /// </summary>
 protected virtual IRecord CreateEmptyRecord(ISchema schema)
 {
     return(new Concrete.Record(schema.Clone()));
 }