> On Jun 10, 2016, at 10:29 AM, Leif Hedstrom <zw...@apache.org> wrote:
> 
> Hi,
> 
> as part generalizing the concept from 
> https://github.com/apache/trafficserver/pull/199 
> <https://github.com/apache/trafficserver/pull/199>, I’ve filed a Jira to add 
> appropriate APIs and I_Machine.h / Machine.cc <http://machine.cc/> support 
> for the concept of a process UUID. The apidefs.h are
> 
> /* --------------------------------------------------------------------------
>     Interface for the UUID APIs. https://www.ietf.org/rfc/rfc4122.txt 
> <https://www.ietf.org/rfc/rfc4122.txt> . */
> typedef enum {
>  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

Is this define useful? I think we should drop it ... in libuuid it is mainly 
used for formatting a string and this API doesn't need that.

> typedef struct tsapi_uuid *TSUuid;
> 
> 
> The ts.h APIs are:
> 
> /* APIs for dealing with UUIDs, either self made, or the system wide process 
> UUID. */
> tsapi TSUuid TSUuidCreate(TSUuidVersion v);

A helpful extension of this might be TSHttpTxnUuidCreate() which would allocate 
the UUID in the transaction arena.

> tsapi TSReturnCode TSUuidDestroy(TSUuid uuid);
> tsapi TSReturnCode TSUuidCopy(TSUuid dest, TSUuid src);
> tsapi TSReturnCode TSUuidInitialize(TSUuid uuid); /* Re-generate the UUID */

If you TSUuidCreate() but don't TSUuidInitialize(), what do you get?

> tsapi const TSUuid TSProcessUuidGet();

Is this persistent across restarts? As we discussed on IRC, it would be good to 
expose this value in metrics and traffic_ctl.

> tsapi const char *TSUuidStringGet(const TSUuid uuid);

Does this return an allocated string?

Consider TSUuid TSUuidStringParse() as an additional API.

> and an additional API to expose the already existing HttpSM (Txn) sequence ID:
> 
> /* Get the Txn's (HttpSM's) unique identifier, which is a sequence number 
> since server start) */
> tsapi int64_t TSHttpTxnIdGet();

Why int64_t rather than uint64_t?

> The APIs are documented in a separate Sphinx file, i.e. no doxygen crud in 
> the ts.h file :).

The documentation should be posted with the review to save a lot of redundant 
questions.

> The TSUuidInitialize() functions is maybe a little confusing, what it does is 
> basically re-initialize the UUID object, thus creating a new UUID value. 
> Also, the UUID implementation does not rely on any external dependency, it’s 
> easy enough to implement this ourselves.
> 
> I’m definitely open for suggestions for improvements and better naming 
> conventions, but of course have reasonable arguments. There will be a couple 
> of more Jira’s to complete Acacio’s initial work here, go get log tags as 
> well as use these UUIDs in e.g. HttpSM diagnostic traces.
> 
> Cheers,
> 
> — leif
> 
> P.s
> It does have regression tests:

Nice!

> 
> [root@fedora ats]# ./bin/traffic_server  -R 1 -r SDK_API_UUID
> traffic_server: using root directory '/opt/ats'
> REGRESSION_TEST initialization begun
> REGRESSION TEST SDK_API_UUID started
> [SDK_API_UUID] TSProcessUuidGet : [TestCase1] <<PASS>> { ok }
> [SDK_API_UUID] TSProcessUuidGet : [TestCase2] <<PASS>> { ok }
> [SDK_API_UUID] TSUuidStringGet : [TestCase1] <<PASS>> { ok }
> [SDK_API_UUID] TSUuidCreate : [TestCase1] <<PASS>> { ok }
> [SDK_API_UUID] TSUuidCopy : [TestCase1] <<PASS>> { ok }
> [SDK_API_UUID] TSUuidCopy : [TestCase2] <<PASS>> { ok }
> [SDK_API_UUID] TSUuidInitialize : [TestCase1] <<PASS>> { ok }
> [SDK_API_UUID] TSUuidInitialize : [TestCase2] <<PASS>> { ok }
> [SDK_API_UUID] TSUuidDestroy : [TestCase1] <<PASS>> { ok }
>    REGRESSION_RESULT SDK_API_UUID:                             PASSED
> REGRESSION_TEST DONE: PASSED
> 

Reply via email to