SDKs
...
v2
Samples
Features
7min
licenses in our sdk support features a license can contain multiple features; each with its own behavior and rules these features can be of different types, such as floating or consumption floating features in the case of floating features , the sdk provides functionality similar to floating licenses a floating feature allows a client to check out a floating slot for a limited time (the floating period ), after which the slot expires unless explicitly released earlier both the local license file and the licensespring platform will reflect the current status of floating slots in use checking out a floating feature to occupy a floating slot for a feature, use checklicensefeature once called, the sdk will store the updated slot usage locally, and you can inspect it using getfeature(featurecode) on the license data 	ld, err = lh checklicensefeature(ctx, featurecode) 	if err != nil { 	 fmt println("feature check error %w", err) 	 return err 	} 	feature = ld getfeature(featurecode) 	fmt printf("floating slots in use %d\n", feature floatinginusecount) the floatinginusecount field indicates how many devices are currently using that feature under this license releasing a floating feature to release a floating slot before the end of the floating period (for example, when shutting down the application), use the following 	ld, err = lh releasefloatinglicensefeature(ctx, featurecode) 	if err != nil { 	 fmt println("error releasing floating feature %w", err) 	 return err 	} 	feature = ld getfeature(featurecode) 	fmt printf("floating slots in use %d\n", feature floatinginusecount) releasing the slot will update both the local license data and the licensespring platform, freeing the slot for other devices consumption features features of the consumption type allow your application to consume usage limits tied to that feature these consumptions may be limited or unlimited, depending on how the feature is configured in the licensespring platform similar to consumption licenses, consumption based features support local usage updates that can later be synced to the cloud local consumption update to register the consumption of a feature locally (i e , increase usage before syncing to the cloud), use the updatefeatureconsumption() method this updates the localconsumptions field in your locally stored license file 	ld, err = lh updatefeatureconsumption(featurecode, 1, true) 	if err != nil { 	 return err 	} 	feature = ld getfeature(featurecode) 	t = feature totalconsumptions 	l = feature localconsumptions 	fmt printf("total consumptions %d\n local consumptions %d\n", t, l) the third argument to updatefeatureconsumption() controls whether the local file should be updated in addition to in memory data, which is what we recommend sync with licensespring server to commit the locally recorded consumption to the licensespring backend, call syncfeatureconsumption() you can provide one or more feature codes to sync specific features no arguments to sync all consumption features at once 	ld, err = lh syncfeatureconsumption(ctx, featurecode) 	if err != nil { 	 return err 	} 	feature = ld getfeature(featurecode) 	t = feature totalconsumptions 	l = feature localconsumptions 	fmt printf("total consumptions %d\n local consumptions %d\n", t, l) after syncing totalconsumptions will reflect the updated count on the licensespring platform localconsumptions will be reset to 0