/// <summary> /// Post event document using processing Route obtained from EventDocument instance and /// serializing document using json. The content type header is not set by this method. /// Note: When returned WriteResult does not satisfy caller requirements, this method does NOT /// give caller a chance to re-post the SAME raw <see cref="Event"/> instance as the onus /// of failure handling is on the caller. /// You can use <see cref="GetRawEventForDocument(IEventProducer, EventDocument, JsonDataMap)"/> /// if you want to re-post the SAME event instance /// </summary> /// <param name="producer">Producer to post event into</param> /// <param name="evtDoc">EventDocument-derivative instance</param> /// <param name="headers">Event headers or null</param> /// <param name="lossMode">Data loss mode, if null then default used from doc declaration</param> /// <returns>WriteResult - how many nodes tried/succeeded/failed</returns> public static async Task <WriteResult> PostEventDocumentAsync(this IEventProducer producer, EventDocument evtDoc, JsonDataMap headers = null, DataLossMode?lossMode = null) { var(attr, partition, rawEvent) = GetRawEventForDocument(producer, evtDoc, headers); var result = await producer.PostAsync(attr.Route, partition, rawEvent, lossMode ?? attr.LossMode).ConfigureAwait(false); return(result); }