{"id":329668,"date":"2022-02-16T09:00:40","date_gmt":"2022-02-16T09:00:40","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=329668"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=329668","title":{"rendered":"<span>\u0427\u0438\u0441\u0442\u044b\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0432 \u0433\u0435\u043a\u0441\u0430\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u043c Go<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0430 \u0447\u0438\u0441\u0442\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 (\u043e\u043d\u0430 \u0436\u0435 \u043b\u0443\u043a\u043e\u0432\u0430\u044f). \u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u044f\u0441\u043d\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043d\u0430 \u043c\u043d\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u043e\u0439. \u0414\u0440\u0443\u0433\u0430\u044f \u043f\u0440\u0438\u044f\u0442\u043d\u0430\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0447\u0438\u0441\u0442\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d\u0430 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0441\u043e\u0447\u0435\u0442\u0430\u0435\u0442\u0441\u044f \u0441 Domain Driven Development \u2014 \u043e\u043d\u0438 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430. <\/p>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0447\u0438\u0441\u0442\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0433\u0435\u043a\u0441\u0430\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u2014 \u043f\u043e\u0434\u0445\u043e\u0434, \u044f\u0432\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0439 \u0441\u043b\u043e\u0438, \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u044b \u0438 \u043f\u0440\u043e\u0447\u0435\u0435. \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0437\u0430\u0441\u043b\u0443\u0436\u0435\u043d\u043d\u043e \u0441\u044b\u0441\u043a\u0430\u043b \u043b\u044e\u0431\u043e\u0432\u044c \u0441\u0440\u0435\u0434\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043d\u0430 Go \u2014 \u043e\u043d \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439 \u0438\u043b\u0438 \u0437\u0443\u0431\u043e\u0434\u0440\u043e\u0431\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0447\u0442\u0438 \u043d\u0438 \u0432 \u0447\u0435\u043c \u043d\u0435 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0440\u0435\u0447\u0438\u0442 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0438\u0434\u0438\u043e\u043c\u0430\u0442\u0438\u043a\u0435 \u044f\u0437\u044b\u043a\u0430 \u2014 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u043c\u0443 Go way. <\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u0447\u0430\u0441\u0442\u043e \u0432\u0438\u0436\u0443 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u0445, \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u0433\u0435\u043a\u0441\u0430\u0433\u043e\u043d\u044b, \u0438 \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u0441\u0430\u043c \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0440\u0435\u0448\u0438\u043b \u2014 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 DDD \u0438 \u043f\u0440\u0435\u0441\u043b\u043e\u0432\u0443\u0442\u043e\u0433\u043e \u0433\u0435\u043a\u0441\u0430\u0433\u043e\u043d\u0430. \u0427\u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u0432\u044b\u0448\u043b\u043e \u044f \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0432 \u044d\u0442\u043e\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0435. <\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<blockquote><p><a href=\"https:\/\/www.kaznacheev.me\/posts\/ru\/chistye-tranzakcii-v-geksagonalnom-go\/\" rel=\"nofollow noopener noreferrer\">\u0421\u0442\u0430\u0442\u044c\u044f \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0430 \u0432 \u043c\u043e\u0435\u043c \u0431\u043b\u043e\u0433\u0435<\/a>.<\/p><\/blockquote>\n<p>  <\/p>\n<h2 id=\"problema-vysokih-abstrakciy\">\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u044b\u0441\u043e\u043a\u0438\u0445 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439<\/h2>\n<p>  <\/p>\n<p>\u0413\u0435\u043a\u0441\u0430\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0438\u043d\u0432\u0435\u0440\u0441\u0438\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: \u0432 \u0446\u0435\u043d\u0442\u0440\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u043e\u043a\u0440\u0443\u0433 \u043d\u0435\u0435 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f (\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043d\u0435\u0435) \u0434\u043e\u043c\u0435\u043d\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430, \u043d\u0430 \u043d\u0435\u0435 \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438\u0434\u0443\u0442 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u044b, \u0441\u043a\u0440\u044b\u0442\u044b\u0435 \u0437\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c\u0438, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u043c\u0438 \u043f\u043e\u0440\u0442\u0430\u043c\u0438. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u0440\u044c\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u043d\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u0430\u0441\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043e\u0442 \u0446\u0435\u043d\u0442\u0440\u0430 \u043a \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438, \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"\/img\/image-loader.svg\" data-src=\"https:\/\/habrastorage.org\/webt\/wv\/jn\/tf\/wvjntfiecbczlkgpbromznj2faq.png\"\/><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043d\u0430 \u043c\u0438\u043d\u0443\u0442\u043e\u0447\u043a\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0434\u0430\u0436\u0443 \u0431\/\u0443 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u0435\u0439.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u043e \u043d\u0435 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439, \u0430 \u0431\u0430\u0437\u043e\u0439, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0435\u0439 ACID \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438. \u0412\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u2014 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u043f\u0440\u044f\u0447\u0435\u043c \u0437\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (\u043f\u043e\u0440\u0442), \u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c. \u0412\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0440\u0442 \u043c\u043e\u0436\u0435\u0442 \u043a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">package port  import ...  \/\/ CarRepository car persistence repository type CarRepository interface {     UpsertCar(ctx context.Context, car *model.Car) error     GetCar(ctx context.Context, id string) (*model.Car, error)     GetCarsBatch(ctx context.Context, ids []string) ([]model.Car, error)     GetCarsByTimePeriod(ctx context.Context, from, to time.Time) ([]model.Car, error)     GetCarsByModel(ctx context.Context, model string) ([]model.Car, error)     DeleteCar(ctx context.Context, id string) error }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u044d\u0442\u043e\u0442 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a DI \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441.<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">package domain  import ...  type Car struct {     carRepo port.CarRepository }  func NewCar(carRepo port.CarRepository) &amp;Car {     return &amp;Car{         carRepo: carRepo,     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u043f\u043e\u0438\u0441\u043a\u0430 \u0430\u0432\u0442\u043e \u043f\u043e \u0433\u043e\u0434\u0443 \u0432\u044b\u043f\u0443\u0441\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u043e\u0439.<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">func (c *Car) GetNewCars(ctx context.Context, from time.Time) ([]model.Car, error) {      if err := c.someValidation(); err := nil {         return nil, fmt.Errorf(\"invalid request: %v\", err)     }      \/\/ read latest cars     cars, err := c.carRepo.GetCarsByTimePeriod(ctx, from, time.Now())     if err := nil {         return nil, fmt.Errorf(\"newest cars read: %v\", err)     }      return c.filterCars(cars), nil }<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0447\u0442\u0435\u043d\u0438\u0435. \u041d\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0447\u0430\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0411\u0414. \u042f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0440\u0430\u0441\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u0432\u044b \u0438 \u0442\u0430\u043a \u0438\u0445 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0437\u043d\u0430\u0435\u0442\u0435. <\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0442\u0443\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u2014 \u043e\u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 (<code>BEGIN<\/code>, <code>COMMIT<\/code> \u0438\u043b\u0438 <code>ROLLBACK<\/code> \u0432 SQL), \u0438 \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0443 \u043a \u043f\u043e\u0440\u043e\u0436\u0434\u0435\u043d\u043d\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u2014 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438. \u0422\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u0441\u0430\u043c\u0430 \u043f\u043e \u0441\u0435\u0431\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u0442\u043e\u0436\u0435 \u043d\u0435 \u0432\u0438\u0442\u0430\u0435\u0442 \u0432 \u043e\u0431\u043b\u0430\u043a\u0430\u0445 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043a\u043e\u0443\u043f\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0430 \u044f\u0432\u043d\u043e \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u0430 \u043a \u0441\u0435\u0441\u0441\u0438\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0432\u0435\u0440\u0445 TCP \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c (\u0434\u0430 \u0438 \u043d\u0435 \u0445\u043e\u0442\u0438\u043c) \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c &#171;\u043d\u0430\u0447\u0430\u043b\u043e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438&#187; \u0438 &#171;\u043a\u043e\u043d\u0435\u0446 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438&#187; \u0432 \u0431\u0438\u0437\u043d\u0435\u0441\u043e\u0432\u043e\u043c \u043a\u043e\u0434\u0435 \u2014 \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u043e\u043c\u0435\u043d\u0430. \u041f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u0430\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u2014 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u2014 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0411\u0414 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u044d\u0442\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043a\u0443\u0440\u0438\u0446\u044b \u0438 \u044f\u0439\u0446\u0430. \u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0442\u0440\u0435\u0431\u0443\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0431\u044b\u043b\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431 \u044d\u0442\u043e\u0439 \u0441\u0430\u043c\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u2014 \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u043a\u0430\u043a \u043d\u0435\u043a\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0441\u043b\u043e\u0439 \u0434\u043e\u043c\u0435\u043d\u0430 \u0438\u043b\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0437\u043d\u0430\u0442\u044c \u043f\u0440\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u0432 \u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u0435 \u0433\u0435\u043a\u0441\u0430\u0433\u043e\u043d\u0430. \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u0432 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u044d\u0442\u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043c\u043e\u043d\u0441\u0442\u0440\u0443\u043e\u0437\u043d\u043e \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u043c (\u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0432\u0440\u043e\u0434\u0435 <code>Select<\/code>, <code>Insert<\/code>, <code>Delete<\/code> \u0438 \u043f\u0440\u043e\u0447\u0438\u043c\u0438 \u2014 \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u043b\u044e\u0431\u0438\u043c\u0443\u044e SQL \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u0432). \u041f\u0440\u0438\u0447\u0435\u043c \u043e\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0430 \u0434\u043b\u044f \u0434\u043e\u043c\u0435\u043d\u0430 \u2014 \u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430, \u0433\u0434\u0435 \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a &#171;\u043d\u0435\u0437\u0430\u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0447\u0435\u043d\u043e\u0439&#187; \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438. <\/p>\n<p>  <\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0439\u0442\u0438 \u0438\u043d\u0430\u0447\u0435, \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u043a\u0430\u043a <code>interface{}<\/code>, \u0430 \u043f\u043e\u0442\u043e\u043c \u0432 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0435 \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043d\u0443\u0436\u043d\u043e\u043c\u0443 \u0442\u0438\u043f\u0443, \u043d\u043e \u044f \u0441\u0447\u0438\u0442\u0430\u044e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435\u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u043c \u0438 \u043d\u0435\u0433\u043e\u0434\u043d\u044b\u043c \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043e\u0447\u0435\u043d\u044c \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0437\u0430\u043c\u0443\u0441\u043e\u0440\u0438\u0432\u0430\u0442\u044c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435\u0439 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u2014 \u0432\u0435\u0434\u044c \u043e\u043d\u0430 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u043c\u0435\u0442\u043e\u0434\u0443, \u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0434 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u0427\u0442\u043e \u0436\u0435 \u0434\u0435\u043b\u0430\u0442\u044c? <\/p>\n<p>  <\/p>\n<h2 id=\"reshenie-predmetnyh-realizaciy\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439<\/h2>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0430\u0440\u0443 \u0441\u043b\u043e\u0432 \u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u0412 \u043f\u043e\u0438\u0441\u043a\u0435 \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f \u0441 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u043c\u0438 \u0432\u0440\u043e\u0434\u0435 <code>UnitOfWork<\/code>, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0445 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u043a\u0430\u043a \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c (\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u043d\u0430\u0435\u0442 \u044f\u0434\u0440\u043e \u0433\u0435\u043a\u0441\u0430\u0433\u043e\u043d\u0430 \u0441 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u043e\u0439). \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a \u043d\u0435\u043a\u0443\u044e \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u2014 \u0432\u0435\u0434\u044c \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u043e\u0433\u043e \u0438 \u043d\u0435\u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u041d\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u044b\u0445 \u0438\u0434\u0435\u0439 \u0432 \u043d\u0435\u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u2014 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0435 \u0444\u0430\u0431\u0440\u0438\u043a\u0438, \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044f \u0438 \u043d\u0435\u043a\u0440\u0430\u0441\u0438\u0432\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0441\u0430\u043c\u043e\u0433\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430. <\/p>\n<p>  <\/p>\n<p>\u0427\u0430\u0441\u0442\u043e \u044d\u0442\u0438 \u0438\u0437\u043e\u0449\u0440\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0434\u0438\u043a\u0442\u043e\u0432\u0430\u043d\u044b \u0436\u0435\u043b\u0430\u043d\u0438\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0431\u0430\u0437\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438\u043b\u0438 \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u0441 \u043e\u0434\u043d\u043e\u0439 \u0411\u0414 \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e, \u0438\u0437\u043c\u0435\u043d\u0438\u0432 \u043b\u0438\u0448\u044c \u043a\u043e\u0434 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 (\u0438 \u043d\u0435 \u043c\u0435\u043d\u044f\u044f \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0438). <\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043d\u044f\u0432, \u0447\u0442\u043e \u044d\u0442\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c &#171;\u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e&#187;, \u0434\u0430 \u0438 \u0432 \u0446\u0435\u043b\u043e\u043c \u043d\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 go way, \u044f \u0432\u044b\u0432\u0435\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u043b\u0438 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443.<\/p>\n<p>  <\/p>\n<h3 id=\"servis-rabotaet-tolko-s-odnoy-bd\">\u0421\u0435\u0440\u0432\u0438\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043e\u0434\u043d\u043e\u0439 \u0411\u0414<\/h3>\n<p>  <\/p>\n<p>\u0418 \u044d\u0442\u043e PosgreSQL. \u041d\u0443 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0430\u0441\u0442\u043e \u043b\u0438 \u0432\u044b \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0435\u0441\u044c \u043c\u0435\u0436\u0434\u0443 \u0411\u0414? \u041c\u043d\u043e\u0433\u0438\u0435 \u0441\u0442\u0430\u0440\u0430\u044e\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u043a\u0438\u0439 \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 generic SQL \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u0442\u044c \u043b\u0438 \u0432 \u044d\u0442\u043e\u043c \u0441\u043c\u044b\u0441\u043b? \u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0441 \u043e\u0434\u043d\u043e\u0439 SQL \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442 \u0432\u0430\u0441 \u043f\u0435\u0440\u0435\u043b\u043e\u043f\u0430\u0442\u0438\u0442\u044c \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0435\u043a\u0442, \u0430 \u043f\u0440\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0441 SQL \u043d\u0430 NoSQL \u0438\u043b\u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 \u0434\u0430\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<h3 id=\"my-ispolzuem-konkretnuyu-biblioteku-dlya-raboty-s-bd\">\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0411\u0414<\/h3>\n<p>  <\/p>\n<p>\u0418 \u044d\u0442\u043e <a href=\"https:\/\/github.com\/go-pg\/pg\" rel=\"nofollow noopener noreferrer\">go-pg<\/a>. \u041b\u0438\u0447\u043d\u043e \u043c\u043d\u0435 \u043e\u043d\u0430 \u043e\u0447\u0435\u043d\u044c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f, \u043a\u0430\u043a \u0431\u0438\u043b\u0434\u0435\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 (\u043d\u0435\u0436\u0435\u043b\u0438 \u043a\u0430\u043a ORM), \u0438 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e. \u0423 \u043d\u0435\u0435 \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u0441\u043a\u0430\u0436\u0443 \u0434\u0430\u043b\u044c\u0448\u0435, \u0431\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u043e\u0432\u043e\u0437\u0438\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u043d\u043e\u0433\u043e. \u041d\u043e \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0435\u0441\u0442\u044c \u0438 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0445, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0435 \u0441\u043f\u0435\u0448\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u043e\u0434.<\/p>\n<p>  <\/p>\n<h3 id=\"k-chemu-prishli-v-itoge\">\u041a \u0447\u0435\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u0438 \u0432 \u0438\u0442\u043e\u0433\u0435<\/h3>\n<p>  <\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0441 \u0447\u0438\u0441\u0442\u044b\u043c \u0441\u0435\u0440\u0434\u0446\u0435\u043c \u0432\u0437\u044f\u043b \u0437\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0432 go-pg. \u041c\u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0441 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0447\u0438\u0441\u0442\u044b\u043c\u0438 (\u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430), \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438\u0434\u0438\u043e\u043c\u0430\u0442\u0438\u0447\u043d\u044b\u043c \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f Go. <\/p>\n<p>  <\/p>\n<p>\u0412 \u0433\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0443\u0442\u0438\u043b\u0438\u0442\u0430\u0440\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043a\u0430\u0441\u0430\u044e\u0442\u0441\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430, \u043d\u043e \u043a\u0430\u0441\u0430\u044e\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u2014 <code>context.Context<\/code>. \u0427\u0430\u0441\u0442\u043e \u0442\u0443\u0434\u0430 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0442\u0435\u043b\u0435\u043c\u0435\u0442\u0440\u0438\u044f, \u043b\u043e\u0433\u0433\u0435\u0440\u044b, \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438 \u0438 \u043f\u0440\u043e\u0447\u0435\u0435. \u0421 \u043c\u043e\u0435\u0439 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0434 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 &#171;\u0443\u0442\u0438\u043b\u0438\u0442\u0430\u0440\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445&#187; \u2014 \u044d\u0442\u043e \u043d\u0435\u043a\u0438\u0439 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043b\u043e\u0433\u0438\u043a\u0443 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u043d\u043e \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u0441\u0432\u0435\u043d\u043d\u043e\u0435 \u0432\u043b\u0438\u044f\u043d\u0438\u0435. \u041e\u0442 \u0441\u043b\u043e\u0432 \u2014 \u043a \u0434\u0435\u043b\u0443!<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">package postgres  import ...  type txKey struct{}  \/\/ injectTx injects transaction to context func injectTx(ctx context.Context, tx *pg.Tx) context.Context {     return context.WithValue(ctx, txKey{}, tx) }  \/\/ extractTx extracts transaction from context func extractTx(ctx context.Context) *pg.Tx {     if tx, ok := ctx.Value(txKey{}).(*pg.Tx); ok {         return tx     }     return nil }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0448\u0430\u0433 \u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430. \u041c\u0435\u0442\u043e\u0434\u044b \u043d\u0435\u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0435, \u0442\u043e \u0435\u0441\u0442\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u2014 \u0437\u0434\u0435\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u0438\u0437 \u043f\u0430\u043a\u0435\u0442\u0430 go-pg \u0431\u0435\u0437\u043e \u0432\u0441\u044f\u043a\u0438\u0445 \u043e\u0431\u0435\u0440\u0442\u043e\u043a \u0438\u043b\u0438 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439. \u041c\u043e\u0436\u0435\u043c \u0441\u0435\u0431\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u044d\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430!<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u0441\u0430\u043c \u0430\u0434\u0430\u043f\u0442\u0435\u0440 (\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439) \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439. \u0418 \u0432\u043e\u0442 \u0442\u0443\u0442 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0435\u0441\u0442\u044c \u0432 go-pg, \u043d\u043e \u043d\u0435\u0442 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 sqlx. \u042d\u0442\u043e \u2014 \u0435\u0434\u0438\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 \u043a\u0430\u043a \u0432 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u0442\u0430\u043a \u0438 \u0431\u0435\u0437 \u043d\u0435\u0435. \u042d\u0442\u043e <code>Select<\/code>, <code>Insert<\/code>, <code>Delete<\/code> \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u2014 \u0443 \u043d\u0438\u0445 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0430\u044f \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u0434\u043b\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0438 \u0431\u0435\u0437, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0437\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u0415\u0441\u043b\u0438 \u043d\u0435\u0442 \u2014 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0431\u0435\u0440\u0442\u043a\u0443. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 go-pg \u0438 \u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0411\u0414, \u0438 \u0443 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>ModelContext(c context.Context, model ...interface{}) *Query<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043e\u0431\u0435\u0440\u0442\u043e\u0447\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0435\u0441\u0442\u044c \u043b\u0438 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f. \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>Query<\/code> \u0438\u0437 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u0430 \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>Query<\/code> \u0438\u0437 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u0430 \u043a \u0411\u0414.<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">package postgres  import ...  \/\/ model returns query model with context with or without transaction extracted from context func (db *Database) model(ctx context.Context, model ...interface{}) *orm.Query {     tx := extractTx(ctx)     if tx != nil {         return tx.ModelContext(ctx, model...)     }     return db.conn.ModelContext(ctx, model...) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c Database \u2014 \u044d\u0442\u043e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0430\u044f <code>CarRepository<\/code>, \u0432 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f SQL \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a PostgreSQL, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u043e\u043d\u043d\u0435\u043a\u0442 (\u043f\u0443\u043b \u043a\u043e\u043d\u0435\u043a\u0442\u043e\u0432) \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0438\u0445 \u043c\u043d\u043e\u0433\u043e.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430, \u0447\u0438\u0442\u0430\u044e\u0449\u0435\u0433\u043e \u043c\u0430\u0448\u0438\u043d\u044b \u0438\u0437 \u0411\u0414, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">package postgres  import ...  func (db *Database) GetCarsByTimePeriod(ctx context.Context, from, to time.Time) ([]model.Car, error) {     var m []model.Car      err := db.model(ctx, &amp;m).         Where(\"manufacture_date BETWEEN ? AND ?\", from, to).         Order(\"model\").         Select()     if err != nil {         return nil, err     }      return m, nil }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u0435\u0442\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0432 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u0442\u0430\u043a \u0438 \u0431\u0435\u0437 \u043d\u0435\u0435 \u2014 \u043d\u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430, \u043d\u0438 \u0441\u0430\u043c \u043c\u0435\u0442\u043e\u0434 \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f. \u041f\u0440\u0438\u0447\u0435\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e, \u0438\u043b\u0438 \u043d\u0435\u0442, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0447\u0430\u0441\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0441 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u043e\u0439. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0436\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e. <\/p>\n<p>  <\/p>\n<h2 id=\"tranzakcii-v-biznese-i-biznes-v-tranzakciyah\">\u0422\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0432 \u0431\u0438\u0437\u043d\u0435\u0441\u0435 \u0438 \u0431\u0438\u0437\u043d\u0435\u0441 \u0432 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f\u0445<\/h2>\n<p>  <\/p>\n<p>\u0414\u0435\u043b\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0437\u0430 \u043c\u0430\u043b\u044b\u043c \u2014 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c &#171;\u0437\u0430\u0440\u044f\u0436\u0435\u043d\u043d\u044b\u0439&#187; \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442, \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0435 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u043e \u0432\u0441\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f, \u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u043c\u043c\u0438\u0442 \u0438\u043b\u0438 \u0440\u043e\u043b\u043b\u0431\u044d\u043a.<\/p>\n<p>  <\/p>\n<p>\u0417\u0432\u0443\u0447\u0438\u0442 \u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u043d\u043e \u043a\u0430\u043a-\u0442\u043e \u043d\u0435\u043a\u0440\u0430\u0441\u0438\u0432\u043e. \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c, \u0432 Go \u0435\u0441\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442? <\/p>\n<p>  <\/p>\n<p>\u0418 \u043e\u043d \u0435\u0441\u0442\u044c! \u042d\u0442\u043e \u2014 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435. \u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u044e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e, \u043d\u0435 \u043e\u0442\u0445\u043e\u0434\u044f \u043e\u0442 \u043a\u0430\u0441\u0441\u044b: <\/p>\n<p>  <\/p>\n<pre><code class=\"go\">package postgres  import ...  \/\/ WithinTransaction runs function within transaction \/\/ \/\/ The transaction commits when function were finished without error func (db *Database) WithinTransaction(ctx context.Context, tFunc func(ctx context.Context) error) error {     \/\/ begin transaction     tx, err := db.conn.Begin()     if err != nil {         return fmt.Errorf(\"begin transaction: %w\", err)     }      \/\/ finalize transaction on panic, etc.     defer tx.Close()      \/\/ run callback     err = tFunc(injectTx(ctx, tx))     if err != nil {         \/\/ if error, rollback         tx.Rollback()         return err     }     \/\/ if no error, commit     tx.Commit()     return nil }<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u0414\u043b\u044f \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0443\u0431\u0440\u0430\u043b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043e\u0448\u0438\u0431\u043e\u043a \u043f\u0440\u0438 \u043a\u043e\u043c\u043c\u0438\u0442\u0435 \u0438 \u0440\u043e\u043b\u043b\u0431\u0435\u043a\u0435<\/em><\/p>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438. \u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439, \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0440\u0432\u0430\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0438 \u043e\u0442\u043c\u0435\u043d\u0435 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 graceful shutdown.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0435\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f commit, \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f rollback, \u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430. <\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0440\u0442 \u2014 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u044e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u0442\u044c!<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">package port  import ...  \/\/ Transactor runs logic inside a single database transaction type Transactor interface {     \/\/ WithinTransaction runs a function within a database transaction.     \/\/     \/\/ Transaction is propagated in the context,     \/\/ so it is important to propagate it to underlying repositories.     \/\/ Function commits if error is nil, and rollbacks if not.     \/\/ It returns the same error.     WithinTransaction(context.Context, func(ctx context.Context) error) error }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 DI \u0432 \u0434\u043e\u043c\u0435\u043d:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">package domain  import ...  type Car struct {     carRepo port.CarRepository     transactor port.Transactor }  func NewCar(transactor port.Transactor, carRepo port.CarRepository) &amp;Car {     return &amp;Car{         carRepo: carRepo,         transactor: transactor,     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0437\u0430\u043c\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u043f\u043e\u0432\u043e\u0434\u0443 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0438, \u0438 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">package domain  import ...  func (c *Car) BuyCar(ctx context.Context, id string, price int, owner model.Owner) error {     if err := c.validateBuyer(ctx, price, owner); err != nil {         return err     }      return c.transactor.WithinTransaction(ctx, func(txCtx context.Context) error {         car, err := c.carRepo.GetCar(txCtx, id)         if err != nil {             return err         }          if err := c.validatePurchase(txCtx, car, owner); err != nil {             return err         }          car.Owner = owner         car.SellPrice = price         car.SellDate = time.Now()          if err := c.carRepo.UpsertCar(txCtx, car); err != nil {             return err         }          log.Printf(\"car %s model % sold to %s for %d\",              car.Id, car.Model, owner.Name, price)          return nil     })  }<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041c\u0438\u043d\u0443\u0442\u043a\u0430 \u0437\u0430\u043d\u0443\u0434\u0441\u0442\u0432\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043b \u043a\u043e\u0434 \u0434\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f. \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0432 \u0433\u0435\u043a\u0441\u0430\u0433\u043e\u043d\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0435 \u0432 \u0441\u043b\u043e\u0435 \u0434\u043e\u043c\u0435\u043d\u0430 (domain service), \u0430 \u0432 \u0441\u043b\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (application service), \u0447\u0442\u043e \u044f \u0438 \u0434\u0435\u043b\u0430\u044e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0436\u0438\u0437\u043d\u0438.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u043e\u043c\u0435\u043d \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043f\u0440\u043e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e, \u0434\u0430 \u0435\u043c\u0443 \u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e. \u0410 \u0441\u043b\u043e\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u0430\u043a \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f\u043c\u0438, \u0442\u0430\u043a \u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 &#171;\u0431\u0438\u0437\u043d\u0435\u0441\u043e\u0432\u044b\u043c\u0438&#187; \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c\u0438, \u0432\u044b\u0445\u043e\u0434\u044f\u0449\u0438\u043c\u0438 \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u0434\u043e\u043c\u0435\u043d\u0430 (\u043a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u0440 \u2014 \u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434 \u0432 CQRS).<\/p>\n<\/div><\/div>\n<p>  <\/p>\n<h2 id=\"uteshitelnye-itogi\">\u0423\u0442\u0435\u0448\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u0442\u043e\u0433\u0438<\/h2>\n<p>  <\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0441\u043b\u043e\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438;<\/li>\n<li>\u0438\u0437\u043e\u043b\u044f\u0446\u0438\u044f \u0443\u0440\u043e\u0432\u043d\u0435\u0439, \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u043d\u0435 \u043f\u0440\u043e\u0442\u0435\u043a\u0430\u044e\u0442;<\/li>\n<li>\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438, \u0432\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0438 \u043e\u0442\u043a\u0430\u0437\u043e\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u0430;<\/li>\n<li>\u0447\u0438\u0441\u0442\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432, \u043d\u0435\u0442 \u043d\u0443\u0436\u0434\u044b \u043f\u0440\u043e\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u0432 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443;<\/li>\n<li>\u043c\u0435\u0442\u043e\u0434\u044b \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u043d\u044b \u043a \u043d\u0430\u043b\u0438\u0447\u0438\u044e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u2014 \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u0435\u0441\u0442\u044c, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u0441\u044f \u0432 \u043d\u0435\u0439, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u2014 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 \u0411\u0414;<\/li>\n<li>commit \u0438 rollback \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041d\u0438\u043a\u0430\u043a\u0438\u0445 defer.<\/li>\n<li>\u043f\u0440\u0438 \u043f\u0430\u043d\u0438\u043a\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f rollback \u0432\u043d\u0443\u0442\u0440\u0438 <code>tx.Close()<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043a \u043b\u044e\u0431\u043e\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u0439 ACID \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u043e\u0431\u0449\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a\u0430\u043a \u0432 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u0442\u0430\u043a \u0438 \u0431\u0435\u0437 \u043d\u0435\u0433\u043e. \u041f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u043e\u0431\u0435\u0440\u0442\u043a\u0443, \u0435\u0441\u043b\u0438 \u0432 \u043b\u044e\u0431\u0438\u043c\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u0442.<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0432 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0411\u0414 \u0432 \u043e\u0434\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0435, \u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0434\u0432\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0432 \u043e\u0434\u043d\u0443. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f \u0432\u0430\u043c \u043d\u0435 \u0437\u0430\u0432\u0438\u0434\u0443\u044e.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0433\u0434\u0435-\u0442\u043e \u044f \u043e\u0442\u043e\u0448\u0435\u043b \u043e\u0442 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u0432 DDD \u0438\u043b\u0438 \u043f\u0440\u0435\u043d\u0435\u0431\u0440\u0435\u0433 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f\u043c\u0438 \u0433\u0435\u043a\u0441\u0430\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b, \u043e\u0434\u043d\u0430\u043a\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0448\u0435\u043b \u043f\u0440\u043e\u0441\u0442\u044b\u043c, \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u043c \u0438 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u043c. <\/p>\n<p>  <\/p>\n<p>\u0410 \u043a\u0430\u043a \u0431\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0432\u044b? \u041f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u044e \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0434\u043b\u044f \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f \u0438\u0434\u0435\u0439 \u0438 \u043a\u0440\u0438\u0442\u0438\u043a\u0438!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><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:\/\/habr.com\/ru\/post\/651799\/\"> https:\/\/habr.com\/ru\/post\/651799\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0430 \u0447\u0438\u0441\u0442\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 (\u043e\u043d\u0430 \u0436\u0435 \u043b\u0443\u043a\u043e\u0432\u0430\u044f). \u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u044f\u0441\u043d\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043d\u0430 \u043c\u043d\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u043e\u0439. \u0414\u0440\u0443\u0433\u0430\u044f \u043f\u0440\u0438\u044f\u0442\u043d\u0430\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0447\u0438\u0441\u0442\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d\u0430 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0441\u043e\u0447\u0435\u0442\u0430\u0435\u0442\u0441\u044f \u0441 Domain Driven Development \u2014 \u043e\u043d\u0438 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430. <\/p>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0447\u0438\u0441\u0442\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0433\u0435\u043a\u0441\u0430\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u2014 \u043f\u043e\u0434\u0445\u043e\u0434, \u044f\u0432\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0439 \u0441\u043b\u043e\u0438, \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u044b \u0438 \u043f\u0440\u043e\u0447\u0435\u0435. \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0437\u0430\u0441\u043b\u0443\u0436\u0435\u043d\u043d\u043e \u0441\u044b\u0441\u043a\u0430\u043b \u043b\u044e\u0431\u043e\u0432\u044c \u0441\u0440\u0435\u0434\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043d\u0430 Go \u2014 \u043e\u043d \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439 \u0438\u043b\u0438 \u0437\u0443\u0431\u043e\u0434\u0440\u043e\u0431\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0447\u0442\u0438 \u043d\u0438 \u0432 \u0447\u0435\u043c \u043d\u0435 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0440\u0435\u0447\u0438\u0442 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0438\u0434\u0438\u043e\u043c\u0430\u0442\u0438\u043a\u0435 \u044f\u0437\u044b\u043a\u0430 \u2014 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u043c\u0443 Go way. <\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u0447\u0430\u0441\u0442\u043e \u0432\u0438\u0436\u0443 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u0445, \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u0433\u0435\u043a\u0441\u0430\u0433\u043e\u043d\u044b, \u0438 \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u0441\u0430\u043c \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0440\u0435\u0448\u0438\u043b \u2014 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 DDD \u0438 \u043f\u0440\u0435\u0441\u043b\u043e\u0432\u0443\u0442\u043e\u0433\u043e \u0433\u0435\u043a\u0441\u0430\u0433\u043e\u043d\u0430. \u0427\u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u0432\u044b\u0448\u043b\u043e \u044f \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0432 \u044d\u0442\u043e\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0435. <\/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-329668","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/329668","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=329668"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/329668\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=329668"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=329668"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=329668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}