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
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);
tsapi TSReturnCode TSUuidDestroy(TSUuid uuid);
tsapi TSReturnCode TSUuidCopy(TSUuid dest, TSUuid src);
tsapi TSReturnCode TSUuidInitialize(TSUuid uuid); /* Re-generate the UUID */
tsapi const TSUuid TSProcessUuidGet();

tsapi const char *TSUuidStringGet(const TSUuid uuid);


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();


The APIs are documented in a separate Sphinx file, i.e. no doxygen crud in the 
ts.h file :). 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:

[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