You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by zwoop <gi...@git.apache.org> on 2016/06/23 21:05:20 UTC

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

GitHub user zwoop opened a pull request:

    https://github.com/apache/trafficserver/pull/736

    TS-4518 Add the basic APIs and code for UUIDs

    This implements the UUID stuff, as well as exposing the TXN ID in a TS API.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/zwoop/trafficserver TS-4518

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/trafficserver/pull/736.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #736
    
----
commit 5e272bd22ac2c51dc7c38fd762fb0ae10460bcf0
Author: Leif Hedstrom <zw...@apache.org>
Date:   2016-06-11T04:03:35Z

    TS-4518 Add the basic APIs and code for UUIDs

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #736: TS-4518 Add the basic APIs and code for UUIDs

Posted by atsci <gi...@git.apache.org>.
Github user atsci commented on the issue:

    https://github.com/apache/trafficserver/pull/736
  
    Linux build *successful*! See https://ci.trafficserver.apache.org/job/Github-Linux/245/ for details.
     



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

Posted by jpeach <gi...@git.apache.org>.
Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/736#discussion_r68608958
  
    --- Diff: doc/developer-guide/api/functions/TSUuidCreate.en.rst ---
    @@ -0,0 +1,138 @@
    +.. Licensed to the Apache Software Foundation (ASF) under one
    +   or more contributor license agreements.  See the NOTICE file
    +   distributed with this work for additional information
    +   regarding copyright ownership.  The ASF licenses this file
    +   to you under the Apache License, Version 2.0 (the
    +   "License"); you may not use this file except in compliance
    +   with the License.  You may obtain a copy of the License at
    +
    +   http://www.apache.org/licenses/LICENSE-2.0
    +
    +   Unless required by applicable law or agreed to in writing, software
    +   distributed under the License is distributed on an "AS IS" BASIS,
    +   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +   See the License for the specific language governing permissions and
    +   limitations under the License.
    +
    +.. include:: ../../../common.defs
    +
    +.. default-domain:: c
    +
    +TSUuidCreate
    +************
    +
    +Traffic Server UUID construction APIs.
    +
    +Synopsis
    +========
    +
    +`#include <ts/ts.h>`
    +
    +.. function:: TSUuid TSUuidCreate(void);
    +.. function:: TSReturnCode TSUuidInitialize(TSUuid uuid, TSUuidVersion v);
    +.. function:: void TSUuidDestroy(TSUuid uuid);
    +.. function:: TSReturnCode TSUuidCopy(TSUuid dest, const TSUuid src);
    +.. function:: const char *TSUuidStringGet(const TSUuid uuid);
    +.. function:: TSUuidVersion TSUuidVersionGet(const TSUuid uuid);
    +.. function:: TSReturnCode TSUuidStringParse(TSUuid uuid, const char *uuid_str);
    +.. function:: const TSUuid TSProcessUuidGet(void);
    +
    +Description
    +===========
    +
    +These APIs are used to create, manage, and use UUIDs in a plugin, implementing
    +part of RFC 4122. Currently, only the V4 variant of the specifications is
    +implemented. In addition, an internal, process unique UUID is provided, which
    +can be used to uniquely identifying the running Traffic Server process.
    +
    +:func:`TSUuidCreate` creates a new :type:`TSUuid` object, which is returned
    +and can be used by the other APIs. Similarly, a read-only global process UUID
    +is returned from the function :func:`TSProcessUuidGet`. You must not attempt
    +to modify any data as returned by either of these functions.
    +
    +:func:`TSUuidInitialize` initializes a :type:`TSUuid` object, using the
    +algorithm defined for the specified version. Note that only the V4 variants is
    +currently supported. You can call :func:`TSUuidInitialize` repeatedly, which
    +each generates a new UUID, but this will overwrite any existing UUID data in
    +the object. This also implies that any strings retrieved using
    +:func:`TSUuidStringGet` are also modified accordingly.
    +
    +:func:`TSUuidDestroy` destroys (releases) an :type:`TSUuid` object, and frees
    +all memory associated with this object. This includes any strings as returned
    +by e.g. :func:`TSUuidStringGet`.
    +
    +:func:`TSUuidCopy` copies one :type:`TSUuid` to another, making an exact
    +duplicate. Note that both the source and the destination UUIDs must be created
    +appropriately, and should not have been previously destroyed.
    +
    +:func:`TSUuidVersionGet` returns the version number for the
    +:type:`TSUuid`. This will work properly for any RFC 4122 initialized UUID
    +object, e.g. if you parse a string with :func:`TSUuidStringParse` this will
    +return the correct variant ID.
    +
    +:func:`TSUuidStringGet` returns a pointer to the internal string
    +representation of the :type:`TSUuid` object. It's important to know that there
    +is no transfer of ownership of this string. If you need a copy of it, you are
    +responsible of doing so yourself. In particular, using a string as returned by
    +:func:`TSUuidStringGet` **after** you have called :func:`TSUuidDestroy` on the
    +corresponding :type:`TSUuid` object is a serious error. The UUID object does
    +not do any sort of reference counting on the string, and you must absolutely
    +not free the memory as returned by this API.
    +
    +Finally, :func:`TSUuidStringParse` can be used to convert an existing
    +:type:`TSUuid` string to a Traffic Server UUID object. This will only succeed
    +if the :type:`TSUuid` string is a proper *RFC 4122* UUID. The :type:`TSUuid`
    +argument passed to this function must be a properly :func:`TSUuidCreate`
    +object, but it does not need to be previously initialized.
    +
    +Return Values
    +=============
    +
    +The :type:`TSUuid` type is an opaque pointer to an internal representation of
    +the UUID object. Several of the functions returns a normal Traffic Server
    +return status code, :type:`TSReturnCode`. You should verify the success of
    +those APIs, of course.
    +
    +The :func:`TSUuidStringGet` function will return ``NULL`` if the :type:`TSUuid`
    +object is not properly inititialized. Likewise, :func:`TSUuidVersionGet` would
    +then return ``TS_UUID_UNDEFINED``.
    +
    +The :func:`TSUuidDestroy` function can not fail, and does not have a return
    +value,  but you are of course responsible for providing a valid :type:`TSUuid`
    +object.
    +
    +Examples
    +========
    +
    +This example uses :func:`TSDebugSpecific` to log a message when a specific
    +debugging flag is enabled::
    +
    --- End diff --
    
    ``.. code-block: c``
    
    Since this is a code snippet


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #736: TS-4518 Add the basic APIs and code for UUIDs

Posted by atsci <gi...@git.apache.org>.
Github user atsci commented on the issue:

    https://github.com/apache/trafficserver/pull/736
  
    FreeBSD build *failed*! See https://ci.trafficserver.apache.org/job/Github-FreeBSD/346/ for details.
     



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #736: TS-4518 Add the basic APIs and code for UUIDs

Posted by atsci <gi...@git.apache.org>.
Github user atsci commented on the issue:

    https://github.com/apache/trafficserver/pull/736
  
    Linux build *successful*! See https://ci.trafficserver.apache.org/job/Github-Linux/242/ for details.
     



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

Posted by jpeach <gi...@git.apache.org>.
Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/736#discussion_r68610169
  
    --- Diff: proxy/api/ts/ts.h ---
    @@ -2389,6 +2392,19 @@ tsapi const char *TSHttpHookNameLookup(TSHttpHookID hook);
     */
     tsapi const char *TSHttpEventNameLookup(TSEvent event);
     
    +/* APIs for dealing with UUIDs, either self made, or the system wide process UUOD. See
    --- End diff --
    
    s/UUOD/UUID/


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

Posted by zwoop <gi...@git.apache.org>.
Github user zwoop commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/736#discussion_r68513514
  
    --- Diff: proxy/InkAPI.cc ---
    @@ -8941,3 +8942,110 @@ TSVConnReenable(TSVConn vconn)
         }
       }
     }
    +
    +// APIs for managing and using UUIDs.
    +TSUuid
    +TSUuidCreate(void)
    +{
    +  ATSUuid *uuid = new ATSUuid();
    +  return (TSUuid)uuid;
    +}
    +
    +TSReturnCode
    +TSUuidDestroy(TSUuid uuid)
    +{
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)uuid) == TS_SUCCESS);
    +  ATSUuid *u = (ATSUuid *)uuid;
    +
    +  if (u->alive()) {
    --- End diff --
    
    It used to do more, but not it just does a poor amount of sanity check, and it certainly can not be a guarantee. It could not be a false negative though. It'd probably make more sense if the data was on a freelist, maybe.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #736: TS-4518 Add the basic APIs and code for UUIDs

Posted by atsci <gi...@git.apache.org>.
Github user atsci commented on the issue:

    https://github.com/apache/trafficserver/pull/736
  
    FreeBSD build *failed*! See https://ci.trafficserver.apache.org/job/Github-FreeBSD/347/ for details.
     



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #736: TS-4518 Add the basic APIs and code for UUIDs

Posted by atsci <gi...@git.apache.org>.
Github user atsci commented on the issue:

    https://github.com/apache/trafficserver/pull/736
  
    FreeBSD build *successful*! See https://ci.trafficserver.apache.org/job/Github-FreeBSD/351/ for details.
     



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

Posted by jpeach <gi...@git.apache.org>.
Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/736#discussion_r68609258
  
    --- Diff: doc/developer-guide/api/types/TSUuid.en.rst ---
    @@ -0,0 +1,48 @@
    +.. Licensed to the Apache Software Foundation (ASF) under one or more
    +   contributor license agreements.  See the NOTICE file distributed
    +   with this work for additional information regarding copyright
    +   ownership.  The ASF licenses this file to you under the Apache
    +   License, Version 2.0 (the "License"); you may not use this file
    +   except in compliance with the License.  You may obtain a copy of
    +   the License at
    +
    +   http://www.apache.org/licenses/LICENSE-2.0
    +
    +   Unless required by applicable law or agreed to in writing, software
    +   distributed under the License is distributed on an "AS IS" BASIS,
    +   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
    +   implied.  See the License for the specific language governing
    +   permissions and limitations under the License.
    +
    +.. include:: ../../../common.defs
    +
    +TSUuid
    +******
    +
    +Synopsis
    +========
    +
    +`#include <ts/apidefs.h>`
    --- End diff --
    
    Consider just including this text in the other man page?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #736: TS-4518 Add the basic APIs and code for UUIDs

Posted by atsci <gi...@git.apache.org>.
Github user atsci commented on the issue:

    https://github.com/apache/trafficserver/pull/736
  
    FreeBSD build *successful*! See https://ci.trafficserver.apache.org/job/Github-FreeBSD/334/ for details.
     



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

Posted by jpeach <gi...@git.apache.org>.
Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/736#discussion_r68609628
  
    --- Diff: doc/developer-guide/api/types/TSUuid.en.rst ---
    @@ -0,0 +1,48 @@
    +.. Licensed to the Apache Software Foundation (ASF) under one or more
    +   contributor license agreements.  See the NOTICE file distributed
    +   with this work for additional information regarding copyright
    +   ownership.  The ASF licenses this file to you under the Apache
    +   License, Version 2.0 (the "License"); you may not use this file
    +   except in compliance with the License.  You may obtain a copy of
    +   the License at
    +
    +   http://www.apache.org/licenses/LICENSE-2.0
    +
    +   Unless required by applicable law or agreed to in writing, software
    +   distributed under the License is distributed on an "AS IS" BASIS,
    +   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
    +   implied.  See the License for the specific language governing
    +   permissions and limitations under the License.
    +
    +.. include:: ../../../common.defs
    +
    +TSUuid
    +******
    +
    +Synopsis
    +========
    +
    +`#include <ts/apidefs.h>`
    --- End diff --
    
    Oh I see there are separate pages for the types ... ok then \U0001f44d 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

Posted by jpeach <gi...@git.apache.org>.
Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/736#discussion_r68463751
  
    --- Diff: proxy/InkAPI.cc ---
    @@ -8941,3 +8942,110 @@ TSVConnReenable(TSVConn vconn)
         }
       }
     }
    +
    +// APIs for managing and using UUIDs.
    +TSUuid
    +TSUuidCreate(void)
    +{
    +  ATSUuid *uuid = new ATSUuid();
    +  return (TSUuid)uuid;
    +}
    +
    +TSReturnCode
    +TSUuidDestroy(TSUuid uuid)
    +{
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)uuid) == TS_SUCCESS);
    +  ATSUuid *u = (ATSUuid *)uuid;
    +
    +  if (u->alive()) {
    --- End diff --
    
    If ``alive()`` is false you have a stale pointer right? At which point how do you know that it was really not alive?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

Posted by jpeach <gi...@git.apache.org>.
Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/736#discussion_r68464100
  
    --- Diff: lib/ts/ink_uuid.h ---
    @@ -0,0 +1,122 @@
    +/** @file
    + *
    + *  Basic implementation of RFC 4122, see
    + *      https://www.ietf.org/rfc/rfc4122.txt
    + *
    + *  @section license License
    + *
    + *  Licensed to the Apache Software Foundation (ASF) under one
    + *  or more contributor license agreements.  See the NOTICE file
    + *  distributed with this work for additional information
    + *  regarding copyright ownership.  The ASF licenses this file
    + *  to you under the Apache License, Version 2.0 (the
    + *  "License"); you may not use this file except in compliance
    + *  with the License.  You may obtain a copy of the License at
    + *
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + *
    + *  Unless required by applicable law or agreed to in writing, software
    + *  distributed under the License is distributed on an "AS IS" BASIS,
    + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + *  See the License for the specific language governing permissions and
    + *  limitations under the License.
    + */
    +#include "ts/apidefs.h"
    +#include "ts/ink_memory.h"
    +
    +// This is the C++ portions of things, which will need to get wrapped in C-helper APIs.
    +class ATSUuid
    +{
    +public:
    +  // Constructors
    +  ATSUuid() : _version(TS_UUID_UNDEFINED), _alive(true) {}
    +  ~ATSUuid() { _alive = false; }
    +  ATSUuid &operator=(const ATSUuid other);
    +
    +  // Initialize the UUID from a string
    +  bool parseString(const char *str);
    +  // Initialize a UUID using appropriate logic for the version specified. This can be done multiple times.
    +  void initialize(TSUuidVersion v);
    +
    +  // This returns the internal string representation of the UUID, do not mess with this string. There is
    +  // no transfer of ownership here. See toString() if you wish to make a copy.
    +  const char *
    +  getString() const
    --- End diff --
    
    JFWIW, consider ``c_str()`` as a STL-type name for this :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

Posted by jpeach <gi...@git.apache.org>.
Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/736#discussion_r68608955
  
    --- Diff: doc/developer-guide/api/functions/TSUuidCreate.en.rst ---
    @@ -0,0 +1,138 @@
    +.. Licensed to the Apache Software Foundation (ASF) under one
    +   or more contributor license agreements.  See the NOTICE file
    +   distributed with this work for additional information
    +   regarding copyright ownership.  The ASF licenses this file
    +   to you under the Apache License, Version 2.0 (the
    +   "License"); you may not use this file except in compliance
    +   with the License.  You may obtain a copy of the License at
    +
    +   http://www.apache.org/licenses/LICENSE-2.0
    +
    +   Unless required by applicable law or agreed to in writing, software
    +   distributed under the License is distributed on an "AS IS" BASIS,
    +   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +   See the License for the specific language governing permissions and
    +   limitations under the License.
    +
    +.. include:: ../../../common.defs
    +
    +.. default-domain:: c
    +
    +TSUuidCreate
    +************
    +
    +Traffic Server UUID construction APIs.
    +
    +Synopsis
    +========
    +
    +`#include <ts/ts.h>`
    +
    +.. function:: TSUuid TSUuidCreate(void);
    +.. function:: TSReturnCode TSUuidInitialize(TSUuid uuid, TSUuidVersion v);
    +.. function:: void TSUuidDestroy(TSUuid uuid);
    +.. function:: TSReturnCode TSUuidCopy(TSUuid dest, const TSUuid src);
    +.. function:: const char *TSUuidStringGet(const TSUuid uuid);
    +.. function:: TSUuidVersion TSUuidVersionGet(const TSUuid uuid);
    +.. function:: TSReturnCode TSUuidStringParse(TSUuid uuid, const char *uuid_str);
    +.. function:: const TSUuid TSProcessUuidGet(void);
    +
    +Description
    +===========
    +
    +These APIs are used to create, manage, and use UUIDs in a plugin, implementing
    +part of RFC 4122. Currently, only the V4 variant of the specifications is
    +implemented. In addition, an internal, process unique UUID is provided, which
    +can be used to uniquely identifying the running Traffic Server process.
    +
    +:func:`TSUuidCreate` creates a new :type:`TSUuid` object, which is returned
    +and can be used by the other APIs. Similarly, a read-only global process UUID
    +is returned from the function :func:`TSProcessUuidGet`. You must not attempt
    +to modify any data as returned by either of these functions.
    +
    +:func:`TSUuidInitialize` initializes a :type:`TSUuid` object, using the
    +algorithm defined for the specified version. Note that only the V4 variants is
    +currently supported. You can call :func:`TSUuidInitialize` repeatedly, which
    +each generates a new UUID, but this will overwrite any existing UUID data in
    +the object. This also implies that any strings retrieved using
    +:func:`TSUuidStringGet` are also modified accordingly.
    +
    +:func:`TSUuidDestroy` destroys (releases) an :type:`TSUuid` object, and frees
    +all memory associated with this object. This includes any strings as returned
    +by e.g. :func:`TSUuidStringGet`.
    +
    +:func:`TSUuidCopy` copies one :type:`TSUuid` to another, making an exact
    +duplicate. Note that both the source and the destination UUIDs must be created
    +appropriately, and should not have been previously destroyed.
    +
    +:func:`TSUuidVersionGet` returns the version number for the
    +:type:`TSUuid`. This will work properly for any RFC 4122 initialized UUID
    +object, e.g. if you parse a string with :func:`TSUuidStringParse` this will
    +return the correct variant ID.
    +
    +:func:`TSUuidStringGet` returns a pointer to the internal string
    +representation of the :type:`TSUuid` object. It's important to know that there
    +is no transfer of ownership of this string. If you need a copy of it, you are
    +responsible of doing so yourself. In particular, using a string as returned by
    +:func:`TSUuidStringGet` **after** you have called :func:`TSUuidDestroy` on the
    +corresponding :type:`TSUuid` object is a serious error. The UUID object does
    +not do any sort of reference counting on the string, and you must absolutely
    +not free the memory as returned by this API.
    +
    +Finally, :func:`TSUuidStringParse` can be used to convert an existing
    +:type:`TSUuid` string to a Traffic Server UUID object. This will only succeed
    +if the :type:`TSUuid` string is a proper *RFC 4122* UUID. The :type:`TSUuid`
    +argument passed to this function must be a properly :func:`TSUuidCreate`
    +object, but it does not need to be previously initialized.
    +
    +Return Values
    +=============
    +
    +The :type:`TSUuid` type is an opaque pointer to an internal representation of
    +the UUID object. Several of the functions returns a normal Traffic Server
    +return status code, :type:`TSReturnCode`. You should verify the success of
    +those APIs, of course.
    +
    +The :func:`TSUuidStringGet` function will return ``NULL`` if the :type:`TSUuid`
    +object is not properly inititialized. Likewise, :func:`TSUuidVersionGet` would
    +then return ``TS_UUID_UNDEFINED``.
    +
    +The :func:`TSUuidDestroy` function can not fail, and does not have a return
    +value,  but you are of course responsible for providing a valid :type:`TSUuid`
    +object.
    +
    +Examples
    +========
    +
    +This example uses :func:`TSDebugSpecific` to log a message when a specific
    +debugging flag is enabled::
    +
    +    #include <ts/apidefs.h>
    --- End diff --
    
    Nuke this line.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

Posted by jpeach <gi...@git.apache.org>.
Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/736#discussion_r68464249
  
    --- Diff: proxy/InkAPI.cc ---
    @@ -8941,3 +8942,110 @@ TSVConnReenable(TSVConn vconn)
         }
       }
     }
    +
    +// APIs for managing and using UUIDs.
    +TSUuid
    +TSUuidCreate(void)
    +{
    +  ATSUuid *uuid = new ATSUuid();
    +  return (TSUuid)uuid;
    +}
    +
    +TSReturnCode
    +TSUuidDestroy(TSUuid uuid)
    +{
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)uuid) == TS_SUCCESS);
    +  ATSUuid *u = (ATSUuid *)uuid;
    +
    +  if (u->alive()) {
    +    delete u;
    +    return TS_SUCCESS;
    +  }
    +
    +  return TS_ERROR;
    +}
    +
    +TSReturnCode
    +TSUuidCopy(TSUuid dest, const TSUuid src)
    +{
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)dest) == TS_SUCCESS);
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)src) == TS_SUCCESS);
    +
    +  ATSUuid *d = (ATSUuid *)dest;
    +  ATSUuid *s = (ATSUuid *)src;
    +
    +  if (d->alive() && s->alive() && s->valid()) {
    +    *d = *s;
    +    return TS_SUCCESS;
    +  }
    +
    +  return TS_ERROR;
    +}
    +
    +TSReturnCode
    +TSUuidInitialize(TSUuid uuid, TSUuidVersion v)
    +{
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)uuid) == TS_SUCCESS);
    +  ATSUuid *u = (ATSUuid *)uuid;
    +
    +  if (u->alive()) {
    +    u->initialize(v);
    +    return u->valid() ? TS_SUCCESS : TS_ERROR;
    +  }
    +
    +  return TS_ERROR;
    +}
    +
    +const TSUuid
    +TSProcessUuidGet(void)
    +{
    +  Machine *machine = Machine::instance();
    +  return (TSUuid)(&machine->uuid);
    +}
    +
    +const char *
    +TSUuidStringGet(const TSUuid uuid)
    +{
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)uuid) == TS_SUCCESS);
    +  ATSUuid *u = (ATSUuid *)(uuid);
    +
    +  if (u->alive() && u->valid()) {
    +    return u->getString();
    +  }
    +
    +  return NULL;
    +}
    +
    +TSReturnCode
    +TSUuidStringParse(TSUuid uuid, const char *str)
    +{
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)uuid) == TS_SUCCESS);
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)str) == TS_SUCCESS);
    +  ATSUuid *u = (ATSUuid *)uuid;
    +
    +  if (u->alive() && u->parseString(str)) {
    +    return TS_SUCCESS;
    +  }
    +
    +  return TS_ERROR;
    +}
    +
    +TSUuidVersion
    +TSUuidVersionGet(TSUuid uuid)
    +{
    --- End diff --
    
    Sanity check?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #736: TS-4518 Add the basic APIs and code for UUIDs

Posted by atsci <gi...@git.apache.org>.
Github user atsci commented on the issue:

    https://github.com/apache/trafficserver/pull/736
  
    FreeBSD build *successful*! See https://ci.trafficserver.apache.org/job/Github-FreeBSD/348/ for details.
     



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #736: TS-4518 Add the basic APIs and code for UUIDs

Posted by atsci <gi...@git.apache.org>.
Github user atsci commented on the issue:

    https://github.com/apache/trafficserver/pull/736
  
    FreeBSD build *successful*! See https://ci.trafficserver.apache.org/job/Github-FreeBSD/350/ for details.
     



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

Posted by jpeach <gi...@git.apache.org>.
Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/736#discussion_r68463465
  
    --- Diff: lib/ts/ink_uuid.h ---
    @@ -0,0 +1,122 @@
    +/** @file
    + *
    + *  Basic implementation of RFC 4122, see
    + *      https://www.ietf.org/rfc/rfc4122.txt
    + *
    + *  @section license License
    + *
    + *  Licensed to the Apache Software Foundation (ASF) under one
    + *  or more contributor license agreements.  See the NOTICE file
    + *  distributed with this work for additional information
    + *  regarding copyright ownership.  The ASF licenses this file
    + *  to you under the Apache License, Version 2.0 (the
    + *  "License"); you may not use this file except in compliance
    + *  with the License.  You may obtain a copy of the License at
    + *
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + *
    + *  Unless required by applicable law or agreed to in writing, software
    + *  distributed under the License is distributed on an "AS IS" BASIS,
    + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + *  See the License for the specific language governing permissions and
    + *  limitations under the License.
    + */
    +#include "ts/apidefs.h"
    +#include "ts/ink_memory.h"
    +
    +// This is the C++ portions of things, which will need to get wrapped in C-helper APIs.
    +class ATSUuid
    +{
    +public:
    +  // Constructors
    +  ATSUuid() : _version(TS_UUID_UNDEFINED), _alive(true) {}
    +  ~ATSUuid() { _alive = false; }
    +  ATSUuid &operator=(const ATSUuid other);
    +
    +  // Initialize the UUID from a string
    +  bool parseString(const char *str);
    +  // Initialize a UUID using appropriate logic for the version specified. This can be done multiple times.
    +  void initialize(TSUuidVersion v);
    +
    +  // This returns the internal string representation of the UUID, do not mess with this string. There is
    +  // no transfer of ownership here. See toString() if you wish to make a copy.
    +  const char *
    +  getString() const
    +  {
    +    return valid() ? _string : NULL;
    +  }
    +
    +  // Copy the UUID string to a buffer of sufficient size (be careful)
    +  bool toString(char *buf);
    --- End diff --
    
    This should be a ``const`` method.
    
    Consider documenting the output buffer size:
    ```C
    bool toString(char buf[36]) const;
    ```
    
    I don't know how you feel about
    ```C
    bool toString(char (&out)[36]) const;
    ```
    ... probably a bit inflexible ...


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

Posted by jpeach <gi...@git.apache.org>.
Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/736#discussion_r68463575
  
    --- Diff: lib/ts/ink_uuid.h ---
    @@ -0,0 +1,122 @@
    +/** @file
    + *
    + *  Basic implementation of RFC 4122, see
    + *      https://www.ietf.org/rfc/rfc4122.txt
    + *
    + *  @section license License
    + *
    + *  Licensed to the Apache Software Foundation (ASF) under one
    + *  or more contributor license agreements.  See the NOTICE file
    + *  distributed with this work for additional information
    + *  regarding copyright ownership.  The ASF licenses this file
    + *  to you under the Apache License, Version 2.0 (the
    + *  "License"); you may not use this file except in compliance
    + *  with the License.  You may obtain a copy of the License at
    + *
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + *
    + *  Unless required by applicable law or agreed to in writing, software
    + *  distributed under the License is distributed on an "AS IS" BASIS,
    + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + *  See the License for the specific language governing permissions and
    + *  limitations under the License.
    + */
    +#include "ts/apidefs.h"
    +#include "ts/ink_memory.h"
    +
    +// This is the C++ portions of things, which will need to get wrapped in C-helper APIs.
    +class ATSUuid
    +{
    +public:
    +  // Constructors
    +  ATSUuid() : _version(TS_UUID_UNDEFINED), _alive(true) {}
    +  ~ATSUuid() { _alive = false; }
    +  ATSUuid &operator=(const ATSUuid other);
    +
    +  // Initialize the UUID from a string
    +  bool parseString(const char *str);
    +  // Initialize a UUID using appropriate logic for the version specified. This can be done multiple times.
    +  void initialize(TSUuidVersion v);
    +
    +  // This returns the internal string representation of the UUID, do not mess with this string. There is
    +  // no transfer of ownership here. See toString() if you wish to make a copy.
    +  const char *
    +  getString() const
    +  {
    +    return valid() ? _string : NULL;
    +  }
    +
    +  // Copy the UUID string to a buffer of sufficient size (be careful)
    +  bool toString(char *buf);
    +
    +  TSUuidVersion
    +  version() const
    +  {
    +    return _version;
    +  }
    +
    +  bool
    +  valid() const
    +  {
    +    return (TS_UUID_UNDEFINED != _version);
    +  }
    +
    +  bool
    +  alive() const
    +  {
    +    return _alive;
    +  }
    --- End diff --
    
    What's the use case for ``alive()``?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #736: TS-4518 Add the basic APIs and code for UUIDs

Posted by atsci <gi...@git.apache.org>.
Github user atsci commented on the issue:

    https://github.com/apache/trafficserver/pull/736
  
    Linux build *successful*! See https://ci.trafficserver.apache.org/job/Github-Linux/228/ for details.
     



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #736: TS-4518 Add the basic APIs and code for UUIDs

Posted by jpeach <gi...@git.apache.org>.
Github user jpeach commented on the issue:

    https://github.com/apache/trafficserver/pull/736
  
    Looks good \U0001f44d 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

Posted by jpeach <gi...@git.apache.org>.
Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/736#discussion_r68464518
  
    --- Diff: proxy/Main.cc ---
    @@ -1674,6 +1674,9 @@ main(int /* argc ATS_UNUSED */, const char **argv)
         machine_addr.assign(HttpConfig::m_master.inbound_ip6);
       Machine::init(0, &machine_addr.sa);
     
    +  RecRegisterStatString(RECT_PROCESS, "proxy.process.version.server.uuid", (char *)Machine::instance()->uuid.getString(),
    +                        RECP_NON_PERSISTENT);
    --- End diff --
    
    Shall we file a separate JIRA to make ``RecRegisterStatString`` take a const value since it is copied?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

Posted by jpeach <gi...@git.apache.org>.
Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/736#discussion_r68464221
  
    --- Diff: proxy/InkAPI.cc ---
    @@ -8941,3 +8942,110 @@ TSVConnReenable(TSVConn vconn)
         }
       }
     }
    +
    +// APIs for managing and using UUIDs.
    +TSUuid
    +TSUuidCreate(void)
    +{
    +  ATSUuid *uuid = new ATSUuid();
    +  return (TSUuid)uuid;
    +}
    +
    +TSReturnCode
    +TSUuidDestroy(TSUuid uuid)
    +{
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)uuid) == TS_SUCCESS);
    +  ATSUuid *u = (ATSUuid *)uuid;
    +
    +  if (u->alive()) {
    +    delete u;
    +    return TS_SUCCESS;
    +  }
    +
    +  return TS_ERROR;
    +}
    +
    +TSReturnCode
    +TSUuidCopy(TSUuid dest, const TSUuid src)
    +{
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)dest) == TS_SUCCESS);
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)src) == TS_SUCCESS);
    +
    +  ATSUuid *d = (ATSUuid *)dest;
    +  ATSUuid *s = (ATSUuid *)src;
    +
    +  if (d->alive() && s->alive() && s->valid()) {
    +    *d = *s;
    +    return TS_SUCCESS;
    +  }
    +
    +  return TS_ERROR;
    +}
    +
    +TSReturnCode
    +TSUuidInitialize(TSUuid uuid, TSUuidVersion v)
    +{
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)uuid) == TS_SUCCESS);
    +  ATSUuid *u = (ATSUuid *)uuid;
    +
    +  if (u->alive()) {
    +    u->initialize(v);
    +    return u->valid() ? TS_SUCCESS : TS_ERROR;
    +  }
    +
    +  return TS_ERROR;
    +}
    +
    +const TSUuid
    +TSProcessUuidGet(void)
    +{
    +  Machine *machine = Machine::instance();
    +  return (TSUuid)(&machine->uuid);
    +}
    +
    +const char *
    +TSUuidStringGet(const TSUuid uuid)
    +{
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)uuid) == TS_SUCCESS);
    +  ATSUuid *u = (ATSUuid *)(uuid);
    +
    +  if (u->alive() && u->valid()) {
    +    return u->getString();
    +  }
    +
    +  return NULL;
    +}
    +
    +TSReturnCode
    +TSUuidStringParse(TSUuid uuid, const char *str)
    +{
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)uuid) == TS_SUCCESS);
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)str) == TS_SUCCESS);
    +  ATSUuid *u = (ATSUuid *)uuid;
    +
    +  if (u->alive() && u->parseString(str)) {
    +    return TS_SUCCESS;
    +  }
    +
    +  return TS_ERROR;
    +}
    +
    +TSUuidVersion
    +TSUuidVersionGet(TSUuid uuid)
    +{
    +  ATSUuid *u = (ATSUuid *)uuid;
    +
    +  if (u->alive()) {
    +    return u->version();
    +  }
    +
    +  return TS_UUID_UNDEFINED;
    +}
    +
    +// Expose the HttpSM's sequence number (ID)
    +uint64_t
    +TSHttpTxnIdGet(TSHttpTxn txnp)
    +{
    --- End diff --
    
    Sanity check?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

Posted by zwoop <gi...@git.apache.org>.
Github user zwoop commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/736#discussion_r68464791
  
    --- Diff: proxy/Main.cc ---
    @@ -1674,6 +1674,9 @@ main(int /* argc ATS_UNUSED */, const char **argv)
         machine_addr.assign(HttpConfig::m_master.inbound_ip6);
       Machine::init(0, &machine_addr.sa);
     
    +  RecRegisterStatString(RECT_PROCESS, "proxy.process.version.server.uuid", (char *)Machine::instance()->uuid.getString(),
    +                        RECP_NON_PERSISTENT);
    --- End diff --
    
    Sure :).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #736: TS-4518 Add the basic APIs and code for UUIDs

Posted by atsci <gi...@git.apache.org>.
Github user atsci commented on the issue:

    https://github.com/apache/trafficserver/pull/736
  
    Linux build *failed*! See https://ci.trafficserver.apache.org/job/Github-Linux/227/ for details.
     



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #736: TS-4518 Add the basic APIs and code for UUIDs

Posted by atsci <gi...@git.apache.org>.
Github user atsci commented on the issue:

    https://github.com/apache/trafficserver/pull/736
  
    FreeBSD build *successful*! See https://ci.trafficserver.apache.org/job/Github-FreeBSD/333/ for details.
     



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

Posted by jpeach <gi...@git.apache.org>.
Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/736#discussion_r68462180
  
    --- Diff: lib/ts/apidefs.h.in ---
    @@ -1125,6 +1173,20 @@ extern tsapi const char *const TS_NPN_PROTOCOL_GROUP_SPDY;
      */
     extern tsapi const TSMLoc TS_NULL_MLOC;
     
    +/* --------------------------------------------------------------------------
    +   Interface for the UUID APIs. https://www.ietf.org/rfc/rfc4122.txt. */
    +typedef enum {
    +  TS_UUID_UNDEFINED = 0,
    +  TS_UUID_V1 = 1,
    +  TS_UUID_V2,
    +  TS_UUID_V3,
    +  TS_UUID_V4, /* At this point, this is the only implemented version (or variant) */
    +  TS_UUID_V5,
    +} TSUuidVersion;
    +
    +#define TSUuidStringLen 36
    --- End diff --
    
    This should be ``TS_UUID_STRING_LEN`` to be consistent with ``TS_MAX_USER_NAME_LEN``, which is the only precedent I could find :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #736: TS-4518 Add the basic APIs and code for UUIDs

Posted by zwoop <gi...@git.apache.org>.
Github user zwoop commented on the issue:

    https://github.com/apache/trafficserver/pull/736
  
    @jpeach  Agree with all the review comments, will address asap and post an update tomorrow (monday).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

Posted by jpeach <gi...@git.apache.org>.
Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/736#discussion_r68462271
  
    --- Diff: lib/ts/ink_uuid.cc ---
    @@ -0,0 +1,109 @@
    +/** @file
    + *
    + *  Basic implementation of RFC 4122, see
    + *      https://www.ietf.org/rfc/rfc4122.txt
    + *
    + *  @section license License
    + *
    + *  Licensed to the Apache Software Foundation (ASF) under one
    + *  or more contributor license agreements.  See the NOTICE file
    + *  distributed with this work for additional information
    + *  regarding copyright ownership.  The ASF licenses this file
    + *  to you under the Apache License, Version 2.0 (the
    + *  "License"); you may not use this file except in compliance
    + *  with the License.  You may obtain a copy of the License at
    + *
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + *
    + *  Unless required by applicable law or agreed to in writing, software
    + *  distributed under the License is distributed on an "AS IS" BASIS,
    + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + *  See the License for the specific language governing permissions and
    + *  limitations under the License.
    + */
    +#include <openssl/rand.h>
    +
    +#include "ts/ink_uuid.h"
    +
    +#include "ts/TestBox.h"
    +#include "ts/TextBuffer.h"
    +
    +void
    +ATSUuid::initialize(TSUuidVersion v)
    +{
    +  switch (v) {
    +  case TS_UUID_UNDEFINED:
    +    ink_release_assert(!"Don't initialize to undefined UUID variant!");
    --- End diff --
    
    ``ink_abort("my message here")``


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #736: TS-4518 Add the basic APIs and code for UUIDs

Posted by atsci <gi...@git.apache.org>.
Github user atsci commented on the issue:

    https://github.com/apache/trafficserver/pull/736
  
    Linux build *successful*! See https://ci.trafficserver.apache.org/job/Github-Linux/244/ for details.
     



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

Posted by jpeach <gi...@git.apache.org>.
Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/736#discussion_r68464023
  
    --- Diff: lib/ts/ink_uuid.h ---
    @@ -0,0 +1,122 @@
    +/** @file
    + *
    + *  Basic implementation of RFC 4122, see
    + *      https://www.ietf.org/rfc/rfc4122.txt
    + *
    + *  @section license License
    + *
    + *  Licensed to the Apache Software Foundation (ASF) under one
    + *  or more contributor license agreements.  See the NOTICE file
    + *  distributed with this work for additional information
    + *  regarding copyright ownership.  The ASF licenses this file
    + *  to you under the Apache License, Version 2.0 (the
    + *  "License"); you may not use this file except in compliance
    + *  with the License.  You may obtain a copy of the License at
    + *
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + *
    + *  Unless required by applicable law or agreed to in writing, software
    + *  distributed under the License is distributed on an "AS IS" BASIS,
    + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + *  See the License for the specific language governing permissions and
    + *  limitations under the License.
    + */
    +#include "ts/apidefs.h"
    +#include "ts/ink_memory.h"
    +
    +// This is the C++ portions of things, which will need to get wrapped in C-helper APIs.
    +class ATSUuid
    +{
    +public:
    +  // Constructors
    +  ATSUuid() : _version(TS_UUID_UNDEFINED), _alive(true) {}
    +  ~ATSUuid() { _alive = false; }
    +  ATSUuid &operator=(const ATSUuid other);
    +
    +  // Initialize the UUID from a string
    +  bool parseString(const char *str);
    +  // Initialize a UUID using appropriate logic for the version specified. This can be done multiple times.
    +  void initialize(TSUuidVersion v);
    +
    +  // This returns the internal string representation of the UUID, do not mess with this string. There is
    +  // no transfer of ownership here. See toString() if you wish to make a copy.
    +  const char *
    +  getString() const
    +  {
    +    return valid() ? _string : NULL;
    +  }
    +
    +  // Copy the UUID string to a buffer of sufficient size (be careful)
    +  bool toString(char *buf);
    --- End diff --
    
    Actually, do you really need this to be public? Callers can just use ``getString()``?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

Posted by jpeach <gi...@git.apache.org>.
Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/736#discussion_r68609126
  
    --- Diff: doc/developer-guide/api/types/TSUuid.en.rst ---
    @@ -0,0 +1,48 @@
    +.. Licensed to the Apache Software Foundation (ASF) under one or more
    +   contributor license agreements.  See the NOTICE file distributed
    +   with this work for additional information regarding copyright
    +   ownership.  The ASF licenses this file to you under the Apache
    +   License, Version 2.0 (the "License"); you may not use this file
    +   except in compliance with the License.  You may obtain a copy of
    +   the License at
    +
    +   http://www.apache.org/licenses/LICENSE-2.0
    +
    +   Unless required by applicable law or agreed to in writing, software
    +   distributed under the License is distributed on an "AS IS" BASIS,
    +   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
    +   implied.  See the License for the specific language governing
    +   permissions and limitations under the License.
    +
    +.. include:: ../../../common.defs
    +
    +TSUuid
    +******
    +
    +Synopsis
    +========
    +
    +`#include <ts/apidefs.h>`
    --- End diff --
    
    We should just use ``<ts/ts.h>`` everywhere.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #736: TS-4518 Add the basic APIs and code for UUIDs

Posted by jpeach <gi...@git.apache.org>.
Github user jpeach commented on the issue:

    https://github.com/apache/trafficserver/pull/736
  
    Looks pretty good to me. I just had some minor comments, mainly style suggestions.
    
    \U0001f44d 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #736: TS-4518 Add the basic APIs and code for UUIDs

Posted by atsci <gi...@git.apache.org>.
Github user atsci commented on the issue:

    https://github.com/apache/trafficserver/pull/736
  
    Linux build *successful*! See https://ci.trafficserver.apache.org/job/Github-Linux/241/ for details.
     



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

Posted by zwoop <gi...@git.apache.org>.
Github user zwoop closed the pull request at:

    https://github.com/apache/trafficserver/pull/736


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

Posted by zwoop <gi...@git.apache.org>.
Github user zwoop commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/736#discussion_r68609243
  
    --- Diff: doc/developer-guide/api/types/TSUuid.en.rst ---
    @@ -0,0 +1,48 @@
    +.. Licensed to the Apache Software Foundation (ASF) under one or more
    +   contributor license agreements.  See the NOTICE file distributed
    +   with this work for additional information regarding copyright
    +   ownership.  The ASF licenses this file to you under the Apache
    +   License, Version 2.0 (the "License"); you may not use this file
    +   except in compliance with the License.  You may obtain a copy of
    +   the License at
    +
    +   http://www.apache.org/licenses/LICENSE-2.0
    +
    +   Unless required by applicable law or agreed to in writing, software
    +   distributed under the License is distributed on an "AS IS" BASIS,
    +   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
    +   implied.  See the License for the specific language governing
    +   permissions and limitations under the License.
    +
    +.. include:: ../../../common.defs
    +
    +TSUuid
    +******
    +
    +Synopsis
    +========
    +
    +`#include <ts/apidefs.h>`
    --- End diff --
    
    That was copied from existing docs.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #736: TS-4518 Add the basic APIs and code for UUI...

Posted by zwoop <gi...@git.apache.org>.
Github user zwoop commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/736#discussion_r68465162
  
    --- Diff: proxy/InkAPI.cc ---
    @@ -8941,3 +8942,110 @@ TSVConnReenable(TSVConn vconn)
         }
       }
     }
    +
    +// APIs for managing and using UUIDs.
    +TSUuid
    +TSUuidCreate(void)
    +{
    +  ATSUuid *uuid = new ATSUuid();
    +  return (TSUuid)uuid;
    +}
    +
    +TSReturnCode
    +TSUuidDestroy(TSUuid uuid)
    +{
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)uuid) == TS_SUCCESS);
    +  ATSUuid *u = (ATSUuid *)uuid;
    +
    +  if (u->alive()) {
    +    delete u;
    +    return TS_SUCCESS;
    +  }
    +
    +  return TS_ERROR;
    +}
    +
    +TSReturnCode
    +TSUuidCopy(TSUuid dest, const TSUuid src)
    +{
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)dest) == TS_SUCCESS);
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)src) == TS_SUCCESS);
    +
    +  ATSUuid *d = (ATSUuid *)dest;
    +  ATSUuid *s = (ATSUuid *)src;
    +
    +  if (d->alive() && s->alive() && s->valid()) {
    +    *d = *s;
    +    return TS_SUCCESS;
    +  }
    +
    +  return TS_ERROR;
    +}
    +
    +TSReturnCode
    +TSUuidInitialize(TSUuid uuid, TSUuidVersion v)
    +{
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)uuid) == TS_SUCCESS);
    +  ATSUuid *u = (ATSUuid *)uuid;
    +
    +  if (u->alive()) {
    +    u->initialize(v);
    +    return u->valid() ? TS_SUCCESS : TS_ERROR;
    +  }
    +
    +  return TS_ERROR;
    +}
    +
    +const TSUuid
    +TSProcessUuidGet(void)
    +{
    +  Machine *machine = Machine::instance();
    +  return (TSUuid)(&machine->uuid);
    +}
    +
    +const char *
    +TSUuidStringGet(const TSUuid uuid)
    +{
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)uuid) == TS_SUCCESS);
    +  ATSUuid *u = (ATSUuid *)(uuid);
    +
    +  if (u->alive() && u->valid()) {
    +    return u->getString();
    +  }
    +
    +  return NULL;
    +}
    +
    +TSReturnCode
    +TSUuidStringParse(TSUuid uuid, const char *str)
    +{
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)uuid) == TS_SUCCESS);
    +  sdk_assert(sdk_sanity_check_null_ptr((void *)str) == TS_SUCCESS);
    +  ATSUuid *u = (ATSUuid *)uuid;
    +
    +  if (u->alive() && u->parseString(str)) {
    +    return TS_SUCCESS;
    +  }
    +
    +  return TS_ERROR;
    +}
    +
    +TSUuidVersion
    +TSUuidVersionGet(TSUuid uuid)
    +{
    --- End diff --
    
    Sanity check?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---