You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by Chris McFarlen <ch...@mcfarlen.us> on 2025/04/01 19:08:19 UTC
Re: [API Proposal] Record reading functions returning std::optional
+1
Sent with Proton Mail secure email.
On Monday, March 31st, 2025 at 6:13 AM, Hiroaki Nakamura <hn...@gmail.com> wrote:
> Hi,
>
> I'd like to change the third API from
>
> RecErrT RecGetRecordString(const char *name, char
> *buf, int buf_len, bool lock = true);
>
> to
>
> std::optionalstd::string_view RecGetRecordString(const char *name,
>
> char *buf, int buf_len, bool lock = true);
>
> as suggested by
> https://github.com/apache/trafficserver/pull/12060#issuecomment-2764549662
>
> 2025年3月30日(日) 21:18 Hiroaki Nakamura hnakamur@gmail.com:
>
> > Hi, I'd like to propose new APIs for record reading functions which
> > return std::optional<T>.
> >
> > std::optional<RecInt> RecGetRecordInt(const char *name, bool lock = true);
> > std::optional<RecFloat> RecGetRecordFloat(const char *name, bool
> > lock = true);
> > RecErrT RecGetRecordString(const char *name, char
> > *buf, int buf_len, bool lock = true);
> > std::optionalstd::string RecGetRecordStringAlloc(const char *name,
> > bool lock = true);
> > std::optional<RecCounter> RecGetRecordCounter(const char *name, bool
> > lock = true);
> >
> > std::optional::has_value() for the result returns true if the value is
> > found or false otherwise.
> > The third API is unmodified from the current API.
> >
> > The prerequisite for these APIs is to prohibit using nullptr as the
> > default value of string records.
> > Therefore we need to change the default value of proxy.config.diags.action.tags
> > from nullptr to an empty string "".
> >
> > For details, please take a look at
> > https://github.com/apache/trafficserver/pull/12060#issuecomment-2763533666
> > and the comments above it.
> >
> > I would appreciate any feedback on this proposal.
> > Thanks,
> >
> > --
> > )Hioraki Nakamura) hnakamur@gmail.com