Sample code
src/main.go
This file contains a sample code to illustrate how to use the SDK to categorize URLs.
You can run the binary directly via docker using ./scripts/client.sh or manually using the toolchain of go.
Note
if you use the binary directly, at least two arguments are required:
the redis DSN with
-rdb -dsn,at least one domain to categorize.
This code imports the package gitlab.olfeo.tech/data-tools/nexus/sdk/redis in as much as rdb from the SDK. It then creates the structure redisDatabase, which implements the interface Database. This interface is passed to the function categorize.NewCategorizer which categorizes the domains.
It returns two pieces of information:
the domain category by calling
Categorizer.GetDomainCategoryandDatabase.GetCategoryInfothe associated application (if present) and its category by calling
Categorizer.GetDomainApplications,Database.GetApplicationInfoandDatabase.GetApplicationCategoryInfo
sdk-sample$ cd src src$ go run main.go -rdb-dsn redis://localhost:6379 dropbox.com Using rdb categorizer from redis://localhost:6379: dropbox.com: (15181) Online Data Storage dropbox.com: application (27) Dropbox application category: (10005) Online Software providing cloud back-ups and data storage infrastructure