-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Embeddings #65
Embeddings #65
Conversation
Co-authored-by: Joel Hoisko <joel.hoisko@gmail.com>
var response = await _caller.Call(_getOneMethod, request, cancellation).ConfigureAwait(false); | ||
response.Failure.ThrowIfFailureIsSet(); | ||
|
||
if (!_toSDK.TryConvert<TEmbedding>(response.State, out var state, out var error)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 5 locations. Consider refactoring.
onSignature) as IOnMethod<TEmbedding>; | ||
} | ||
|
||
Type GetOnMethodSignature(MethodInfo method) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
=> eventTypes.GetFor(typeof(TEvent)); | ||
|
||
/// <inheritdoc/> | ||
public Task<Try<ProjectionResult<TReadModel>>> TryOn(TReadModel readModel, object @event, EmbeddingProjectContext context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
throw new InvalidProjectionMethodReturnType(method.ReturnType); | ||
} | ||
|
||
Type GetTypedOnMethodSignature(MethodInfo method) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
readonly Type _embeddingType = typeof(TEmbedding); | ||
|
||
/// <inheritdoc/> | ||
public void BuildAndRegister( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method BuildAndRegister
has 57 lines of code (exceeds 25 allowed). Consider refactoring.
return true; | ||
} | ||
|
||
bool TryAddConventionRemoveMethod( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
return okay; | ||
} | ||
|
||
IRemoveMethod<TEmbedding> CreateRemoveMethod(MethodInfo method) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
return okay; | ||
} | ||
|
||
ICompareMethod<TEmbedding> CreateCompareMethod(MethodInfo method) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
cancellation); | ||
} | ||
|
||
bool TryAddOnMethods(IEventTypes eventTypes, IDictionary<EventType, IOnMethod<TReadModel>> eventTypesToMethods, ILogger logger) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
.ForCompare(embeddingId, eventTypes, loggerFactory) | ||
.TryBuild(out var compareMethod)) | ||
{ | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid too many return
statements within this method.
return true; | ||
} | ||
|
||
bool TryAddConventionUpdateMethod( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
return okay; | ||
} | ||
|
||
IUpdateMethod<TEmbedding> CreateUpdateMethod(MethodInfo method) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
return okay; | ||
} | ||
|
||
IDeleteMethod<TEmbedding> CreateDeleteMethod(MethodInfo method) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
return true; | ||
} | ||
|
||
bool TryAddDecoratedUpdateMethod( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
.ForDelete(embeddingId, eventTypes, loggerFactory) | ||
.TryBuild(out var deleteMethod)) | ||
{ | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid too many return
statements within this method.
// Copyright (c) Dolittle. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
return true; | ||
} | ||
|
||
bool TryAddDecoratedDeleteMethod( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
/// </summary> | ||
/// <param name="method">The out of the method.</param> | ||
/// <returns>A bool indicating whether the build succeeded.</returns> | ||
public bool TryBuild(out IUpdateMethod<TEmbedding> method) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
/// </summary> | ||
/// <param name="method">The out of the method.</param> | ||
/// <returns>A bool indicating whether the build succeeded.</returns> | ||
public bool TryBuild(out IDeleteMethod<TEmbedding> method) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
} | ||
|
||
/// <inheritdoc/> | ||
public async Task<ProjectionResult<TReadModel>> On(TReadModel readModel, object @event, EventType eventType, EmbeddingProjectContext context, CancellationToken cancellation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
Summary
Adds a new feature, Embeddings! They are similar to Projections, but they are meant to be used to event source changes coming from an external system. Check the sample for an example.
Added
WithEmbeddings()
builder, or by specifying theResolveUpdateToEvents
,ResolveDeletionToEvents
andOn
methods or attributes for a class. The embeddings can be updated, deleted and fetched from theclient.Embeddings
property.