Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to extend the serializer in the latest version? #8394

Closed
gpetrou opened this issue Oct 18, 2024 · 3 comments
Closed

How to extend the serializer in the latest version? #8394

gpetrou opened this issue Oct 18, 2024 · 3 comments

Comments

@gpetrou
Copy link
Contributor

gpetrou commented Oct 18, 2024

Once again there are breaking changes in a patch version.
Before the latest version, we had the following class:

internal class ExtendedSystemTextJsonSerializer : SystemTextJsonSerializer
{
    public ExtendedSystemTextJsonSerializer(IElasticsearchClientSettings elasticsearchClientSettings)
        : base(elasticsearchClientSettings)
    {
        JsonSerializerOptions options = DefaultSourceSerializer.CreateDefaultJsonSerializerOptions(includeDefaultConverters: true);

        options.Converters.Add(new ObjectConverter());

        Options = DefaultSourceSerializer.AddDefaultConverters(options);
    }

    protected JsonSerializerOptions Options { get; set; }

    protected override JsonSerializerOptions CreateJsonSerializerOptions() => Options;
}

We were calling it as in the following code:

ElasticsearchClientSettings elasticsearchClientSettings = new(
    nodePool,
    sourceSerializer: (defaultSerializer, settings) =>
        new ExtendedSystemTextJsonSerializer(settings));

How is this supposed to be transformed now in the latest version? We do not need the IElasticsearchClientSettings anymore?

@flobernd flobernd added 8.x Relates to 8.x client version Area: Transport Category: Question labels Oct 18, 2024
@flobernd
Copy link
Member

Hi @gpetrou,

This got even easier now:

ElasticsearchClientSettings elasticsearchClientSettings = new(
    nodePool,
    sourceSerializer: (defaultSerializer, settings) =>
        new DefaultSourceSerializer(settings, options => options.Converters.Add(/*...*/)));

Please let me know, if that answers your question.

PS: We still don't use semantic versioning.

Copy link
Contributor

This issue is stale because it has been open 5 days with no activity. Remove stale label or comment or this will be closed in 2 days.

Copy link
Contributor

This issue was closed because it has been stalled for 2 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants