The plugin system provides a means to create specialized objects in Drupal that do not require the data storage features of the entity system.
This recipe is based on the GeoIP API module port to Drupal 8 that was started by the author. The GeoIP API module provides a way to get the country from a website visitor's IP address.
In this recipe, we will create a new plugin type called GeoLocator that will return the country code for a given IP address. We will create a plugin manager, a default plugin interface, a plugin annotation definition, and provide a default plugin to find the country via the website's CDN.