{"id":287010,"date":"2017-05-29T14:45:03","date_gmt":"2017-05-29T10:45:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=287010"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=287010","title":{"rendered":"\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u043f\u0440\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0432 scala"},"content":{"rendered":"<p>\u0412 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0432\u0441\u0442\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0445\u043e\u0434\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0441\u043a\u043b\u0430\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043d\u0435\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u0430\u043a \u043d\u0435\u043b\u044c\u0437\u044f \u043b\u0443\u0447\u0448\u0435 \u0441\u043b\u0443\u0436\u0438\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438. \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u0435\u0437\u0431\u043e\u043b\u0435\u0437\u043d\u0435\u043d\u043d\u043e, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0412 \u043c\u0438\u0440\u0435 java, \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e (\u043d\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430), \u043a\u0430\u0436\u0434\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u0432\u043e\u0451\u043c \u043f\u043e\u0442\u043e\u043a\u0435. \u0418 \u0442\u0443\u0442 \u0432\u0441\u0451 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <b>ThreadLocal<\/b> \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438:  <\/p>\n<pre><code class=\"java\">class Context {   public static final ThreadLocal&lt;Context&gt; global = new ThreadLocal&lt;Context&gt;; }   \/\/\u0433\u0434\u0435-\u0442\u043e \u0432 \u043c\u0435\u0441\u0442\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 Context context = new Context(...); Context.global.set(context); try {   someService.someMethod(); } finally {   Context.global.set(null); } <\/code><\/pre>\n<p>  \u0412 scala \u0436\u0435, \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e, \u0432\u0441\u0451 \u043d\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e, \u0438 \u043f\u043e \u0445\u043e\u0434\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u0442\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0441\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f \u043d\u0435\u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \u043e\u0447\u0435\u043d\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445. \u0418 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441 <b>ThreadLocal<\/b> \u0443\u0436\u0435 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 (\u043a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432 java, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435). <br \/>  \u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0439\u0442\u0438 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443, \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0447\u0435\u0440\u0435\u0437 \u0438\u043c\u043f\u043b\u0438\u0441\u0438\u0442\u043d\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.  <\/p>\n<pre><code class=\"scala\">def foo(bar: Bar)(implicit context: Context) <\/code><\/pre>\n<p>  \u041d\u043e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0445\u043b\u0430\u043c\u043b\u044f\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432. \u041f\u043e\u043b\u043e\u043c\u0430\u0432 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0433\u043e\u043b\u043e\u0432\u0443, \u043f\u0440\u0438\u0448\u043b\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0438\u0434\u0435\u044f: \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u0438 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u043f\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c \u043f\u043e \u043c\u0435\u0440\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<br \/>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043d\u0430\u0448 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"scala\">\/\/data - \u0441\u043a\u043b\u0430\u0434 \u0434\u043b\u044f \u0432\u0441\u044f\u043a\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 class Context(val operationId: String, val data: TrieMap[String, String] = TrieMap.empty) <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0440\u0435\u0439\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u043c\u0435\u0447\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b:  <\/p>\n<pre><code class=\"scala\">trait ContextualObject {   protected def context: Option[Context] }   \/\/\u043e\u0431\u044a\u0435\u043a\u0442, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u0439 \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 trait ChangeableContextualObject[T &lt;: ContextualObject] extends ContextualObject {   def withContext(ctx: Option[Context]): T }   \/\/\u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u043f\u0443\u0441\u0442\u044b\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c trait EmptyContext {   _: ContextualObject =&gt;     override protected val context: Option[Context] = None } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u043d\u0430\u0448\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:  <\/p>\n<pre><code class=\"scala\">\/\/\u0413\u043e\u0432\u043e\u0440\u0438\u043c, \u0447\u0442\u043e \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0438\u0441 \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 trait ServiceA extends ChangeableContextualObject[ServiceA] {   def someSimpleOperation: Int     def someLongOperation(implicit executionContext: ExecutionContext): Future[Int] }   trait ServiceAImpl extends ServiceA {     override def someSimpleOperation: Int = 1     override def someLongOperation(implicit executionContext: ExecutionContext): Future[Int] = {     Future(someSimpleOperation)       .map { res =&gt;         \/\/\u0437\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u0430\u043a\u0438\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u043e\u043d \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442         context.foreach(_.data.put(&quot;ServiceA.step1&quot;, res.toString))         res * Random.nextInt(10)       }       .map { res =&gt;         context.foreach(_.data.put(&quot;ServiceA.step2&quot;, res.toString))         res - Random.nextInt(5)       }       .andThen {         case Success(res) =&gt; context.foreach(_.data.put(&quot;ServiceA.step3&quot;, res.toString))       }   }     \/\/\u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u0435\u0440\u0432\u0438\u0441 \u0441 \u043d\u0443\u0436\u043d\u044b\u043c \u043d\u0430\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c   override def withContext(ctx: Option[Context]): ServiceA = new ServiceAImpl {     ctx.foreach(_.data.put(&quot;ServiceA.withContext&quot;, &quot;true&quot;))     override protected def context: Option[Context] = ctx   } }   object ServiceAImpl {   def apply(): ServiceAImpl = new ServiceAImpl with EmptyContext } <\/code><\/pre>\n<p>  \u0418 \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0435\u0440\u0432\u0438\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439:  <\/p>\n<pre><code class=\"scala\">trait ServiceB extends ChangeableContextualObject[ServiceB] {   def someOperationWithoutServiceA: Int     def someOperationWithServiceA(implicit executionContext: ExecutionContext): Future[Boolean] }   \/**   * \u041f\u0440\u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043c\u043e\u0433 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441:    * \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043d\u0435 \u043a\u043b\u0430\u0441\u0441 \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u0441\u0435\u0440\u0432\u0438\u0441 \u0410 \u0443\u043a\u0430\u0437\u0430\u043d \u043a\u0430\u043a \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434?   * \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u043e\u0442\u0432\u0435\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0448\u0438\u0432\u0430\u043d\u0438\u0435 EmptyContext \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430,   * \u043d\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 withContext.   * \u0422\u0430\u043a\u0436\u0435, \u043a\u0430\u043a \u0431\u043e\u043d\u0443\u0441, \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c cake pattern \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430   *\/ trait ServiceBImpl extends ServiceB {   self =&gt;   protected def serviceA: ServiceA     override def someOperationWithoutServiceA: Int = 1     override def someOperationWithServiceA(implicit executionContext: ExecutionContext): Future[Boolean] = {     serviceA.someLongOperation.map {       case res if res % 2 == 0 =&gt;         context.foreach(_.data.put(&quot;ServiceB.res&quot;, &quot;even&quot;))         true         case res =&gt;         context.foreach(_.data.put(&quot;ServiceB.res&quot;, &quot;odd&quot;))         false     }   }     override def withContext(ctx: Option[Context]): ServiceB = new ServiceBImpl {     ctx.foreach(_.data.put(&quot;ServiceB.withContext&quot;, &quot;true&quot;))     override protected val context: Option[Context] = ctx     \/\/ \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0442\u043e\u0442 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u043c\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u043b\u0438 \u0441\u0435\u0440\u0432\u0438\u0441 \u0410 \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044e     \/\/ \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0435\u0435 \u043a\u0430\u043a lazy val,     \/\/ \u0438 \u044d\u0442\u043e\u0442 \u0441\u0435\u0440\u0432\u0438\u0441 \u0431\u0443\u0434\u0435\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d \u0441 \u043d\u043e\u0432\u044b\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u043d\u043e.     \/\/ \u042d\u0442\u043e \u044f \u0438 \u043d\u0430\u0437\u0432\u0430\u043b \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430     override protected lazy val serviceA: ServiceA = self.serviceA.withContext(ctx)   } }   object ServiceBImpl {   \/\/ \u0415\u0441\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a - \u043d\u0443\u0436\u043d\u043e \u043b\u0438\u0431\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043e\u0442 \u0442\u0435\u0445,   \/\/ \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0441\u0435, \u043b\u0438\u0431\u043e \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c \u0438\u0445 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.   \/\/ \u041d\u043e \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0442\u0430\u043a:   \/\/ class Builder(val serviceA: ServiceA) extends ServiceBImpl with EmptyContext   \/\/ \u0418 \u0432 \u043c\u0435\u0441\u0442\u0435 \u0432\u044b\u0437\u043e\u0432\u0430:   \/\/ new ServiceBImpl.Builder(serviceA)   \/\/ \u0418\u043c\u044f, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u0435 \u0441\u0430\u043c\u043e\u0435 \u0443\u0434\u0430\u0447\u043d\u043e\u0435, \u043d\u043e \u0438\u0434\u0435\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u0430.   def apply(a: ServiceA): ServiceBImpl = new ServiceBImpl with EmptyContext {     \/\/  \u0430 \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043a\u0430\u043a val     override protected val serviceA: ServiceA = a   } } <\/code><\/pre>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435, \u0432 \u043c\u0435\u0441\u0442\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"scala\">val context = new Context(&quot;opId&quot;) val serviceBWithContext = serviceB.withContext(Some(context)) serviceBWithContext.someOperationWithoutServiceA context.data.get(&quot;ServiceB.withContext&quot;) \/\/ Some(&quot;true&quot;) context.data.get(&quot;ServiceA.withContext&quot;) \/\/ None   serviceBWithContext.someOperationWithServiceA.andThen {   case _ =&gt;      context.data.get(&quot;ServiceA.withContext&quot;) \/\/ Some(&quot;true&quot;)     context.data.get(&quot;ServiceA.step1&quot;) \/\/ Some(&quot;1&quot;) } <\/code><\/pre>\n<p>  \u0412\u0441\u0451 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e \u0445\u043e\u0434\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442. \u041d\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u0441\u0435\u0433\u043e \u043d\u0430\u0439\u0442\u0438 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u044b \u0432 \u0445\u043e\u0434\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0438 \u0432\u0430\u0436\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0445\u043e\u0442\u0438\u043c \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0437\u0430\u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0421\u0430\u043c\u044b\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u0431\u044b\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0433\u0435\u0440 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430, \u0438 \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043b\u043e\u0433 \u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044e \u043f\u0440\u0438\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u043d\u0451\u043c. \u041d\u043e \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u043d\u0435 \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435).<\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043d\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430, \u0441\u0434\u0435\u043b\u0430\u0435\u043c <b>ThreadLocal<\/b> \u0441 \u043d\u0430\u0448\u0438\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c:  <\/p>\n<pre><code class=\"scala\">object Context {   val global: ThreadLocal[Option[Context]] = ThreadLocal.withInitial[Option[Context]](() =&gt; None)     \/\/\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435   def runWith[T](context: Context)(operation: =&gt; T): T = {     runWith(Some(context))(operation)   }     \/\/\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435   def runWith[T](context: Option[Context])(operation: =&gt; T): T = {     val old = global.get()     global.set(context)     \/\/ \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0432\u0435\u0440\u043d\u0435\u043c \u0441\u0442\u0430\u0440\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439     try operation finally global.set(old)    } } <\/code><\/pre>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <b>logback-classic<\/b> \u0434\u043b\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 Layout \u0434\u043b\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"scala\">class OperationContextLayout extends LayoutBase[ILoggingEvent] {   private val separator: String = System.getProperty(&quot;line.separator&quot;)     override def doLayout(event: ILoggingEvent): String = {     val sb = new StringBuilder(256)     sb.append(event.getFormattedMessage)       .append(separator)       appendContextParams(sb)     appendStack(event, sb)     sb.toString()   }     private def appendContextParams(sb: StringBuilder): Unit = {     Context.global.get().foreach { ctx =&gt;       sb.append(&quot;operationId=&quot;)         .append(ctx.operationId)         ctx.data.readOnlySnapshot().foreach {         case (key, value) =&gt;           sb.append(&quot; &quot;).append(key).append(&quot;=&quot;).append(value)       }         sb.append(separator)     }   }     private def appendStack(event: ILoggingEvent, sb: StringBuilder): Unit = {     if (event.getThrowableProxy != null) {       val converter = new ThrowableProxyConverter       converter.setOptionList(List(&quot;full&quot;).asJava)       converter.start()         sb.append()     }   } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u043a\u043e\u043d\u0444\u0438\u0433<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"xml\">&lt;configuration&gt;       &lt;appender name=&quot;STDOUT&quot; class=&quot;ch.qos.logback.core.ConsoleAppender&quot;&gt;         &lt;encoder class=&quot;ch.qos.logback.core.encoder.LayoutWrappingEncoder&quot;&gt;             &lt;layout class=&quot;operation.context.logging.OperationContextLayout&quot; \/&gt;         &lt;\/encoder&gt;     &lt;\/appender&gt;       &lt;root level=&quot;debug&quot;&gt;         &lt;appender-ref ref=&quot;STDOUT&quot; \/&gt;     &lt;\/root&gt; &lt;\/configuration&gt; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0418 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0437\u0430\u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c:  <\/p>\n<pre><code class=\"scala\">  def runWithoutA(): Unit = {     val context = Some(createContext())     val res = serviceB.withContext(context).someOperationWithoutServiceA     Context.runWith(context) {       \/\/ Result of someOperationWithoutServiceA: '1'       \/\/ operationId=GPapC6JKmY ServiceB.withContext=true       logger.info(s&quot;Result of someOperationWithoutServiceA: '$res'&quot;)     }   } <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"scala\">  def runWithA(): Future[_] = {     val context = Some(createContext())     serviceB.withContext(context).someOperationWithServiceA.andThen {       case _ =&gt;         Context.runWith(context) {           \/\/ someOperationWithServiceA completed           \/\/ operationId=XU1SGXPq1N ServiceB.res=even ServiceA.withContext=true ServiceB.withContext=true ServiceA.step1=1 ServiceA.step2=7 ServiceA.step3=4           logger.info(&quot;someOperationWithServiceA completed&quot;)         }     }   } <\/code><\/pre>\n<p>  \u0418 \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441: \u043a\u0430\u043a \u0436\u0435 \u0431\u044b\u0442\u044c \u0441 \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u043a\u043e\u0434\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 <b>ExecutionContext<\/b>? \u041d\u043e \u043d\u0430\u043c \u0436\u0435 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0440\u0430\u043f\u043f\u0435\u0440 \u0434\u043b\u044f \u043d\u0435\u0433\u043e:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u0440\u0430\u043f\u043f\u0435\u0440\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"scala\">class ContextualExecutionContext(context: Option[Context], executor: ExecutionContext) extends ExecutionContext {     override def execute(runnable: Runnable): Unit = executor.execute(() =&gt; {     Context.runWith(context)(runnable.run())   })     override def reportFailure(cause: Throwable): Unit = {     Context.runWith(context)(executor.reportFailure(cause))   }   }   object ContextualExecutionContext {   implicit class ContextualExecutionContextOps(val executor: ExecutionContext) extends AnyVal {     def withContext(context: Option[Context]): ContextualExecutionContext = new ContextualExecutionContext(context, executor)   } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u043d\u0435\u0448\u043d\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"scala\">class SomeExternalObject {   val logger: Logger = LoggerFactory.getLogger(classOf[SomeExternalObject])     def externalCall(implicit executionContext: ExecutionContext): Future[Int] = {     Future(1).andThen {       case Success(res) =&gt; logger.debug(s&quot;external res $res&quot;)     }   } } <\/code><\/pre>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u0432 \u043d\u0430\u0448\u0435\u043c <b>ExecutionContext<\/b>:  <\/div>\n<\/div>\n<p>  <\/p>\n<pre><code class=\"scala\">  def runExternal(): Future[_] = {     val context = Some(createContext())     implicit val executor = global.withContext(context)     \/\/ external res 1     \/\/ operationId=8Hf277SV7B     someExternalObject.externalCall   } <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0438 \u0432\u0441\u044f \u0438\u0434\u0435\u044f. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c. \u041c\u043e\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u044d\u0442\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0432\u0441\u0451, \u0447\u0442\u043e \u0443\u0433\u043e\u0434\u043d\u043e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043b\u0435\u043f\u043e\u043a \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u0418 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435, \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043b\u0435\u0436\u0435\u043d\u0438\u044f \u0437\u0430 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c \u043f\u0440\u0438 \u043e\u0431\u0449\u0435\u043d\u0438\u0438 \u0430\u043a\u0442\u043e\u0440\u043e\u0432, \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u0434\u043e\u043f\u043e\u043b\u043d\u044e \u0441\u0442\u0430\u0442\u044c\u044e. \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0438\u0434\u0435\u0438 \u043f\u043e \u043f\u043e\u0432\u043e\u0434\u0443 \u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0442\u0430\u043a\u0436\u0435 \u043f\u0438\u0448\u0435\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c.<\/p>\n<p>  P.S. \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/github.com\/eld0727\/scala-operation-context\">github.com\/eld0727\/scala-operation-context<\/a><br \/>  P.P.S. \u042f \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d \u0438 \u043a \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u043c, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u0438 \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 scala.<br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/323682\/\"> https:\/\/habrahabr.ru\/post\/323682\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0432\u0441\u0442\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0445\u043e\u0434\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0441\u043a\u043b\u0430\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043d\u0435\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u0430\u043a \u043d\u0435\u043b\u044c\u0437\u044f \u043b\u0443\u0447\u0448\u0435 \u0441\u043b\u0443\u0436\u0438\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438. \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u0435\u0437\u0431\u043e\u043b\u0435\u0437\u043d\u0435\u043d\u043d\u043e, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-287010","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/287010","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=287010"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/287010\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=287010"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=287010"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=287010"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}