It is always good to know how to use core services and as well how to create your own service. Following code snippet can help you to do that.
Create custom service into modulename.service.yml
services: content_connected.manager: class: Drupal\content_connected\ContentConnectedManager arguments: ["@entity.manager", "@config.factory","@entity.query", "@module_handler","@renderer","@string_translation"]
You can see the details code in (http://cgit.drupalcode.org/content_connected?h=8.x-1.x)
Module link :- https://www.drupal.org/project/content_connected