SDKs
...
v2
Samples

Consumption License

3min
licenses of type consumption allow you to use a limited or unlimited number of consumable units, which can be applied based on your application’s needs for example, our sdk provides a simple two step process for managing consumptions local consumption – you update the locally stored license file to reflect usage, without communicating with the server yet sync with server – you synchronize the updated license state with the licensespring cloud server at this stage, the actual consumption is registered on the server and reflected on the platform updateconsumption this method updates the localconsumptions value in the local license file, if the value alligns with license's specifications 	ld, err = lh updateconsumption(1) 	t = ld totalconsumptions 	l = ld localconsumptions 	fmt printf("total consumptions %d\n local consumptions %d\n", t, l) syncconsumption this method synchronizes the current localconsumptions value with the licensespring cloud server if the sync is successful and no errors are returned, the local license file is updated as follows totalconsumptions is incremented (or decremented) based on the local value localconsumptions is reset to zero this update will also be visible on the licensespring platform dashboard syncconsumption also can request the server to allow overages the second argument is whether to ask for overages and the third is the number of overages requested, if any if overages requested, the change will be reflected both in local license file and platform 	ld, err = lh syncconsumption(ctx, false, 0) 	t = ld totalconsumptions 	l = ld localconsumptions 	fmt printf("total consumptions %d\n local consumptions %d\n", t, l)