public Dispatcher(IDependencyResolver dependencyResolver, IJobCoordinator jobCoordinator, IErrorHandlingPolicy errorHandlingPolicy, IMethodBinder methodBinder, IEventStream eventStream, IRecoverableAction recoverableAction, IStatusChanger statusChanger, IContinuationLiveness continuationLiveness, IExceptionFilterDispatcher exceptionFilterDispatcher, IJobRootValidator jobRootValidator) { if (jobCoordinator == null) throw new ArgumentNullException("jobCoordinator"); if (dependencyResolver == null) throw new ArgumentNullException("dependencyResolver"); if (errorHandlingPolicy == null) throw new ArgumentNullException("errorHandlingPolicy"); if (methodBinder == null) throw new ArgumentNullException("methodBinder"); if (eventStream == null) throw new ArgumentNullException("eventStream"); if (recoverableAction == null) throw new ArgumentNullException("recoverableAction"); if (statusChanger == null) throw new ArgumentNullException("statusChanger"); if (continuationLiveness == null) throw new ArgumentNullException("continuationLiveness"); if (exceptionFilterDispatcher == null) throw new ArgumentNullException("exceptionFilterDispatcher"); if (jobRootValidator == null) throw new ArgumentNullException("jobRootValidator"); _jobCoordinator = jobCoordinator; _dependencyResolver = dependencyResolver; _errorHandlingPolicy = errorHandlingPolicy; _methodBinder = methodBinder; _eventStream = eventStream; _recoverableAction = recoverableAction; _statusChanger = statusChanger; _continuationLiveness = continuationLiveness; _exceptionFilterDispatcher = exceptionFilterDispatcher; _jobRootValidator = jobRootValidator; }
public CallProxy(IClientTransport transport, IMethodCallSerializer serializer, IMethodBinder binder, string targetName) { _transport = transport; _serializer = serializer; _binder = binder; _targetName = targetName; }
public CallProxy(IClientTransport transport, IMethodCallSerializer serializer, IMethodBinder binder, string targetName) { _transport = transport; _serializer = serializer; _binder = binder; _targetName = targetName; }
public void SerializeCall(Stream stream, IMethodBinder info, string target, MethodCall call) { var writer = XmlWriter.Create(stream); writer.WriteStartElement("MethodCall"); writer.WriteElementString("Target", target); writer.WriteElementString("MethodSignature", Convert.ToBase64String(info.GetMethodSignature(call.Method))); writer.WriteStartElement("Arguments"); var ctx = Cache.GetContext(); var parameters = call.Method.GetParameters(); for (int i = 0; i < parameters.Length; i++) { var parameter = parameters[i]; var serializer = ctx[parameter.ParameterType]; var container = serializer.Create(); container.Value = call.Arguments[i]; serializer.Serializer.Serialize(writer, container); } writer.WriteEndElement(); writer.WriteEndElement(); writer.Flush(); }
public OkHeyResponse(IMethodBinder methodBinder, IScheduleType scheduleType, IHttpReturnType returnType) { _methodBinder = methodBinder; _scheduleType = scheduleType; _returnType = returnType; _log = LogManager.GetLogger(GetType()); }
public RequestHandler(ITargetSelector selector, IMethodBinder binder, IMethodCallSerializer serializer, IMethodCallInterceptor interceptor) { _selector = selector; _binder = binder; _serializer = serializer; _interceptor = interceptor; }
public void TestThatTheResolverReturnCorrectlyWhenCantFindTheMethod() { ResolveMethodByFireMeAttribute resolver = new ResolveMethodByFireMeAttribute(); IMethodBinder method = resolver.Find(new HeyRememberDto() { Domain = "Hey.Api.Rest.Tests", Type = "", Name = "ThisMethodDoesntExists" }); Assert.AreEqual(MethodExecutionResultEnum.Empty, method.Invoke()); }
public void TestThatTheResolverCanFindTheFireMeMethod() { ResolveMethodByFireMeAttribute resolver = new ResolveMethodByFireMeAttribute(); IMethodBinder method = resolver.Find(new HeyRememberDto() { Domain = "Hey.Api.Rest.Tests", Type = "", Name = "BindMe" }); Assert.AreEqual(method.Name, nameof(ResolveMethodByFireMeAttributeTestClass.RetrieveMe)); }
public MethodCall DeserializeCall(Stream stream, IMethodBinder binder, ITargetSelector selector, object callContext) { var reader = CreateReader(stream).MoveToContent(); var rv = new MethodCall { Target = selector.GetTarget(reader.ReadProperty("Target").ToString(), callContext) }; var osig = reader.ReadProperty("MethodSignature"); var sig = osig as byte[] ?? Convert.FromBase64String((string)osig); rv.Method = binder.GetInfoProviderFor(rv.Target).GetMethod(sig); reader.ExpectProperty("Arguments"); var args = rv.Method.GetParameters(); if (_serializer.TypeNameHandling >= TypeNameHandling.All) { rv.Arguments = _serializer.Deserialize <object[]>(reader); for (var c = 0; c < rv.Arguments.Length && c < args.Length; c++) { if (args[c].ParameterType.GetTypeInfo().IsPrimitive) { rv.Arguments[c] = Convert.ChangeType(rv.Arguments[c], args[c].ParameterType); } } reader.Next(); } else { rv.Arguments = new object[args.Length]; if (reader.TokenType != JsonToken.StartArray) { throw new ArgumentException("Arguments should be an array"); } for (var c = 0; c < args.Length; c++) { rv.Arguments[c] = _serializer.Deserialize(reader.Next(), args[c].ParameterType); } if (reader.Next().TokenType != JsonToken.EndArray) { throw new ArgumentException("Expected end array"); } reader.Next(); } reader.MoveToEnd(); return(rv); }
public RpcExecHelper( HttpClient http, string uri, Dictionary <string, string> headers, ITargetNameExtractor extractor = null, IMethodBinder binder = null, JsonSerializerSettings settings = null) { _http = http; _uri = uri; _headers = headers; _settings = settings; _extractor = extractor ?? new AspNetCoreTargetNameExtractor(); _binder = binder ?? new DefaultMethodBinder(); }
public void SerializeCall(Stream stream, IMethodBinder binder, string target, MethodCall call) { var sig = binder.GetMethodSignature(call.Method); using (var writer = CreateWriter(stream)) { writer.WriteStartObject(); writer.WritePropertyName("Target"); writer.WriteValue(target); writer.WritePropertyName("MethodSignature"); writer.WriteValue(_useBson ? (object)sig : Convert.ToBase64String(sig)); writer.WritePropertyName("Arguments"); _serializer.Serialize(writer, call.Arguments); writer.WriteEndObject(); } }
public MethodExecutionResultEnum Execute(HeyRememberDto heyRemember) { var now = DateTime.UtcNow; if (now < heyRemember.When[0].ToUniversalTime()) { _log.Info($"{heyRemember}, will be executed on {heyRemember.When[0]}"); return(MethodExecutionResultEnum.Empty); } ResolveMethodByFireMeAttribute resolveMethod = new ResolveMethodByFireMeAttribute(_exceptionHandler); IMethodBinder binder = resolveMethod.Find(heyRemember); MethodExecutionResultEnum result = binder.Invoke(); _log.Info($"execution of {heyRemember}: {result}"); if (result != MethodExecutionResultEnum.Ok) { throw new DeferredExecutionException($"The execution of {heyRemember} failed: see logs for details"); } return(result); }
public MethodCall DeserializeCall(Stream stream, IMethodBinder info, ITargetSelector selector) { var reader = XmlReader.Create(stream); while (reader.NodeType != XmlNodeType.Element) { reader.Read(); } var rv = new MethodCall(); reader.ReadStartElement("MethodCall"); //Skip root node rv.Target = selector.GetTarget(reader.ReadElementContentAsString()); rv.Method = info.GetInfoProviderFor(rv.Target).GetMethod(Convert.FromBase64String(reader.ReadElementContentAsString())); reader.ReadStartElement("Arguments"); var ctx = Cache.GetContext(); rv.Arguments = rv.Method.GetParameters().Select(parameter => ((ISerializable)ctx[parameter.ParameterType].Serializer.Deserialize(reader)).Value).ToArray(); return(rv); }
public HeyResponseFactory(IMethodBinder methodBinder) { _methodBinder = methodBinder; }
public Engine(IMethodCallSerializer serializer, IMethodBinder binder) { _binder = binder; _serializer = serializer; }
public BinderCanCallTheMethod(IMethodBinder methodBinder) { Can = false; ExecutionResultEnum = methodBinder.Invoke(this); Can = Can && ExecutionResultEnum == MethodExecutionResultEnum.Ok; }
public RequestHandler(ITargetSelector selector, IMethodBinder binder, IMethodCallSerializer serializer) { _selector = selector; _binder = binder; _serializer = serializer; }
public IHeyResponse UpdateResponse(IScheduleType schedulePrototype) { IMethodBinder methodBinder = _resolveMethod.Find(_heyRemember); return(new HeyResponseFactory(methodBinder).Make(schedulePrototype, new CreatedHttpReturn())); }