<commit_before>﻿using System;
using System.Collections.Generic;
using Redola.ActorModel;

namespace Redola.Rpc
{
    public class RpcActor
    {
        public static readonly IActorMessageEncoder DefaultActorMessageEncoder = new ActorMessageEncoder(new ProtocolBuffersMessageEncoder());
        public static readonly IActorMessageDecoder DefaultActorMessageDecoder = new ActorMessageDecoder(new ProtocolBuffersMessageDecoder());

        private BlockingRouteActor _localActor = null;

        public RpcActor()
            : this(AppConfigActorConfiguration.Load())
        {
        }

        public RpcActor(ActorConfiguration configuration)
            : this(configuration, DefaultActorMessageEncoder, DefaultActorMessageDecoder)
        {
        }

        public RpcActor(ActorConfiguration configuration, IActorMessageEncoder encoder, IActorMessageDecoder decoder)
        {
            if (configuration == null)
                throw new ArgumentNullException("configuration");
            if (encoder == null)
                throw new ArgumentNullException("encoder");
            if (decoder == null)
                throw new ArgumentNullException("decoder");

            _localActor = new BlockingRouteActor(configuration, encoder, decoder);
        }

        public BlockingRouteActor Actor { get { return _localActor; } }
        public IActorMessageEncoder Encoder { get { return _localActor.Encoder; } }
        public IActorMessageDecoder Decoder { get { return _localActor.Decoder; } }

        public void Bootup()
        {
            _localActor.Bootup();
        }

        public void Bootup(IActorDirectory directory)
        {
            _localActor.Bootup(directory);
        }

        public void Shutdown()
        {
            _localActor.Shutdown();
        }

        public void RegisterRpcService(RpcService service)
        {
            _localActor.RegisterMessageHandler(service);
        }

        #region Blocking Envelope

        public ActorMessageEnvelope<P> Send<R, P>(ActorIdentity remoteActor, ActorMessageEnvelope<R> request)
        {
            return Send<R, P>(remoteActor, request, TimeSpan.FromSeconds(30));
        }

        public ActorMessageEnvelope<P> Send<R, P>(ActorIdentity remoteActor, ActorMessageEnvelope<R> request, TimeSpan timeout)<commit_msg>expose the actor active status<commit_after>﻿using System;
using System.Collections.Generic;
using Redola.ActorModel;

namespace Redola.Rpc
{
    public class RpcActor
    {
        public static readonly IActorMessageEncoder DefaultActorMessageEncoder = new ActorMessageEncoder(new ProtocolBuffersMessageEncoder());
        public static readonly IActorMessageDecoder DefaultActorMessageDecoder = new ActorMessageDecoder(new ProtocolBuffersMessageDecoder());

        private BlockingRouteActor _localActor = null;

        public RpcActor()
            : this(AppConfigActorConfiguration.Load())
        {
        }

        public RpcActor(ActorConfiguration configuration)
            : this(configuration, DefaultActorMessageEncoder, DefaultActorMessageDecoder)
        {
        }

        public RpcActor(ActorConfiguration configuration, IActorMessageEncoder encoder, IActorMessageDecoder decoder)
        {
            if (configuration == null)
                throw new ArgumentNullException("configuration");
            if (encoder == null)
                throw new ArgumentNullException("encoder");
            if (decoder == null)
                throw new ArgumentNullException("decoder");

            _localActor = new BlockingRouteActor(configuration, encoder, decoder);
        }

        internal BlockingRouteActor Actor { get { return _localActor; } }
        public bool Active { get { return _localActor.Active; } }
        public IActorMessageEncoder Encoder { get { return _localActor.Encoder; } }
        public IActorMessageDecoder Decoder { get { return _localActor.Decoder; } }

        public void Bootup()
        {
            _localActor.Bootup();
        }

        public void Bootup(IActorDirectory directory)
        {
            _localActor.Bootup(directory);
        }

        public void Shutdown()
        {
            _localActor.Shutdown();
        }

        public void RegisterRpcService(RpcService service)
        {
            _localActor.RegisterMessageHandler(service);
        }

        #region Blocking Envelope

        public ActorMessageEnvelope<P> Send<R, P>(ActorIdentity remoteActor, ActorMessageEnvelope<R> request)
        {
            return Send<R, P>(remoteActor, request, TimeSpan.FromSeconds(30));
        }

        public ActorMessageEnvelope<P> Send<R, P>(ActorIdentity remoteActor, ActorMessageEnvelope<R> request, TimeSpan timeout)
{'fraction_non_alphanumeric': 0.07265047518479409, 'fraction_numerical': 0.0008447729672650475, 'mean_word_length': 2.643076923076923, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1986908', 'n_tokens_mistral': 1159, 'n_tokens_neox': 1097, 'n_words': 269}