This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class BulletTrainRemoteConfiguration : IRemoteConfiguration | |
| { | |
| private readonly string _userIdentity; | |
| private static readonly object LockObject = new object(); | |
| public BulletTrainRemoteConfiguration(RemoteConfigurationSettings settings) | |
| { | |
| if (BulletTrainClient.instance == null) | |
| lock (LockObject) | |
| if (BulletTrainClient.instance == null) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // main interface | |
| public interface IRemoteConfiguration | |
| { | |
| Task<List<Feature>> GetFeatures(); | |
| Task<List<Setting>> GetSettings(List<string> keys = null); | |
| Task<bool> IsFeatureEnabled(string key); | |
| Task<string> GetSettingValue(string key); | |
| } | |
| // other classes | |
| public abstract class RemoteConfigEntry |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: '2' | |
| services: | |
| zookeeper1: | |
| restart: always | |
| image: wurstmeister/zookeeper:latest | |
| container_name: zookeeper1 | |
| ports: | |
| - "2181:2181" | |
| kafka1: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class AuthHeadersInterceptor : Interceptor | |
| { | |
| public AuthHeadersInterceptor(IHttpContextAccessor httpContextAccessor) | |
| { | |
| _httpContextAccessor = httpContextAccessor; | |
| } | |
| public override AsyncUnaryCall<TResponse> AsyncUnaryCall<TRequest, TResponse>(TRequest request, ClientInterceptorContext<TRequest, TResponse> context, AsyncUnaryCallContinuation<TRequest, TResponse> continuation) | |
| { | |
| var metadata = new Metadata |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| httpClientBuilder.ConfigureChannel(o => | |
| { | |
| // add SSL credentials | |
| o.Credentials = new SslCredentials(); | |
| // allow invalid/untrusted certificates | |
| var httpClientHandler = new HttpClientHandler | |
| { | |
| ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator | |
| }; | |
| var httpClient = new HttpClient(httpClientHandler); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| services.AddTransient<AuthHeadersInterceptor>(); | |
| services.AddHttpContextAccessor(); | |
| var httpClientBuilder = services.AddGrpcClient<MygRpcService.MygRpcServiceClient>(o => { o.Address = new Uri("grpc-endpoint-url"); }); | |
| httpClientBuilder.AddInterceptor<AuthHeadersInterceptor>(); | |
| httpClientBuilder.ConfigureChannel(o => o.Credentials = ChannelCredentials.Insecure); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class JwtTokenValidator : ISecurityTokenValidator | |
| { | |
| public bool CanReadToken(string securityToken) => true; | |
| public ClaimsPrincipal ValidateToken(string securityToken, TokenValidationParameters validationParameters, out SecurityToken validatedToken) | |
| { | |
| var handler = new JwtSecurityTokenHandler(); | |
| var tokenValidationParameters = new TokenValidationParameters | |
| { | |
| ValidateIssuer = true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void ConfigureServices(...) { | |
| services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) | |
| .AddJwtBearer(o => { | |
| var validator = new JwtTokenValidator(...); | |
| o.SecurityTokenValidators.Add(validator); | |
| }); | |
| services.AddAuthorization(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void Configure(...) { | |
| app.UseRouting(); | |
| app.UseAuthentication(); | |
| app.UseAuthorization(); | |
| app.UseEndpoints(... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function memorySizeOf(obj) { | |
| var bytes = 0; | |
| function sizeOf(obj) { | |
| if(obj !== null && obj !== undefined) { | |
| switch(typeof obj) { | |
| case 'number': | |
| bytes += 8; | |
| break; | |
| case 'string': |