Skip to content

Commit

Permalink
Merge pull request #229 from betwixt-labs/rename-rpc
Browse files Browse the repository at this point in the history
rename 'xrpc' to 'tempo'
  • Loading branch information
Andrew authored Apr 30, 2023
2 parents 79fcbdd + e623f4a commit b373c54
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION="2.5.3"
VERSION="2.5.4"
MAJOR=2
MINOR=5
PATCH=3
PATCH=4
2 changes: 1 addition & 1 deletion Core/Generators/BaseGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected BaseGenerator(BebopSchema schema)
/// <param name="services">Determines which components of a service will be generated. default to both client and server.</param>
/// <param name="writeGeneratedNotice">Whether a generation notice should be written at the top of files. This is true by default.</param>
/// <returns>The generated code.</returns>
public abstract string Compile(Version? languageVersion, XrpcServices services = XrpcServices.Both, bool writeGeneratedNotice = true);
public abstract string Compile(Version? languageVersion, TempoServices services = TempoServices.Both, bool writeGeneratedNotice = true);

/// <summary>
/// Write auxiliary files to an output directory path.
Expand Down
2 changes: 1 addition & 1 deletion Core/Generators/CPlusPlus/CPlusPlusGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ private string EmitLiteral(Literal literal) {
/// Generate code for a Bebop schema.
/// </summary>
/// <returns>The generated code.</returns>
public override string Compile(Version? languageVersion, XrpcServices services = XrpcServices.Both, bool writeGeneratedNotice = true)
public override string Compile(Version? languageVersion, TempoServices services = TempoServices.Both, bool writeGeneratedNotice = true)
{
var builder = new StringBuilder();
if (writeGeneratedNotice)
Expand Down
2 changes: 1 addition & 1 deletion Core/Generators/CSharp/CSharpGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public CSharpGenerator(BebopSchema schema) : base(schema)
}


public override string Compile(Version? languageVersion, XrpcServices services = XrpcServices.Both, bool writeGeneratedNotice = true)
public override string Compile(Version? languageVersion, TempoServices services = TempoServices.Both, bool writeGeneratedNotice = true)
{
if (languageVersion is not null)
{
Expand Down
2 changes: 1 addition & 1 deletion Core/Generators/Dart/DartGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ private string EmitLiteral(Literal literal) {
/// Generate code for a Bebop schema.
/// </summary>
/// <returns>The generated code.</returns>
public override string Compile(Version? languageVersion, XrpcServices services = XrpcServices.Both, bool writeGeneratedNotice = true)
public override string Compile(Version? languageVersion, TempoServices services = TempoServices.Both, bool writeGeneratedNotice = true)
{
var builder = new StringBuilder();
builder.AppendLine("import 'dart:typed_data';");
Expand Down
2 changes: 1 addition & 1 deletion Core/Generators/Rust/RustGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class RustGenerator : BaseGenerator

public RustGenerator(BebopSchema schema) : base(schema) { }

public override string Compile(Version? languageVersion, XrpcServices services = XrpcServices.Both, bool writeGeneratedNotice = true)
public override string Compile(Version? languageVersion, TempoServices services = TempoServices.Both, bool writeGeneratedNotice = true)
{
// the main scope which is where we write the const definitions and the borrowed types (as these are the
// primary way to use bebop in Rust)
Expand Down
2 changes: 1 addition & 1 deletion Core/Generators/ServiceGeneratorFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Core.Generators
/// <summary>
/// An enum that defines which parts of a service are generated
/// </summary>
public enum XrpcServices
public enum TempoServices
{
/// <summary>
/// Indicates no service code should be generated
Expand Down
30 changes: 15 additions & 15 deletions Core/Generators/TypeScript/TypeScriptGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ private string EmitLiteral(Literal literal) {
/// Generate code for a Bebop schema.
/// </summary>
/// <returns>The generated code.</returns>
public override string Compile(Version? languageVersion, XrpcServices services = XrpcServices.Both, bool writeGeneratedNotice = true)
public override string Compile(Version? languageVersion, TempoServices services = TempoServices.Both, bool writeGeneratedNotice = true)
{
var builder = new IndentedStringBuilder();
if (writeGeneratedNotice)
Expand All @@ -379,14 +379,14 @@ public override string Compile(Version? languageVersion, XrpcServices services =
builder.AppendLine("import { BebopView, BebopRuntimeError, BebopRecord } from \"bebop\";");
if (Schema.Definitions.Values.OfType<ServiceDefinition>().Any())
{
if (services is XrpcServices.Client or XrpcServices.Both)
if (services is TempoServices.Client or TempoServices.Both)
{
builder.AppendLine("import { Metadata } from \"@xrpc/common\";");
builder.AppendLine("import { BaseClient, MethodInfo, CallOptions } from \"@xrpc/client\";");
builder.AppendLine("import { Metadata } from \"@tempojs/common\";");
builder.AppendLine("import { BaseClient, MethodInfo, CallOptions } from \"@tempojs/client\";");
}
if (services is XrpcServices.Server or XrpcServices.Both)
if (services is TempoServices.Server or TempoServices.Both)
{
builder.AppendLine("import { ServiceRegistry, BaseService, ServerContext, BebopMethodAny, BebopMethod } from \"@xrpc/server\";");
builder.AppendLine("import { ServiceRegistry, BaseService, ServerContext, BebopMethodAny, BebopMethod } from \"@tempojs/server\";");
}
}

Expand Down Expand Up @@ -595,9 +595,9 @@ public override string Compile(Version? languageVersion, XrpcServices services =
}
}
var serviceDefinitions = Schema.Definitions.Values.OfType<ServiceDefinition>();
if (serviceDefinitions is not null && serviceDefinitions.Any() && services is not XrpcServices.None)
if (serviceDefinitions is not null && serviceDefinitions.Any() && services is not TempoServices.None)
{
if (services is XrpcServices.Server or XrpcServices.Both)
if (services is TempoServices.Server or TempoServices.Both)
{
foreach(var service in serviceDefinitions)
{
Expand All @@ -612,25 +612,25 @@ public override string Compile(Version? languageVersion, XrpcServices services =
builder.AppendLine();
}

builder.CodeBlock("export class XrpcServiceRegistry extends ServiceRegistry", indentStep, () =>
builder.CodeBlock("export class TempoServiceRegistry extends ServiceRegistry", indentStep, () =>
{
builder.AppendLine("private static readonly staticServiceInstances: Map<string, BaseService> = new Map<string, BaseService>();");
builder.CodeBlock("public static register(serviceName: string)", indentStep, () =>
{
builder.CodeBlock("return (constructor: Function) =>", indentStep, () =>
{
builder.AppendLine("const service = Reflect.construct(constructor, [undefined]);");
builder.CodeBlock("if (XrpcServiceRegistry.staticServiceInstances.has(serviceName))", indentStep, () =>
builder.CodeBlock("if (TempoServiceRegistry.staticServiceInstances.has(serviceName))", indentStep, () =>
{
builder.AppendLine("throw new Error(`Duplicate service registered: ${serviceName}`);");
});
builder.AppendLine("XrpcServiceRegistry.staticServiceInstances.set(serviceName, service);");
builder.AppendLine("TempoServiceRegistry.staticServiceInstances.set(serviceName, service);");
});

});
builder.CodeBlock("public static tryGetService(serviceName: string): BaseService", indentStep, () =>
{
builder.AppendLine("const service = XrpcServiceRegistry.staticServiceInstances.get(serviceName);");
builder.AppendLine("const service = TempoServiceRegistry.staticServiceInstances.get(serviceName);");
builder.CodeBlock("if (service === undefined)", indentStep, () =>
{
builder.AppendLine("throw new Error(`Unable to retreive service '${serviceName}' - it is not registered.`);");
Expand All @@ -649,13 +649,13 @@ public override string Compile(Version? languageVersion, XrpcServices services =
{

builder.AppendLine($"serviceName = '{service.ClassName()}';");
builder.AppendLine($"service = XrpcServiceRegistry.tryGetService(serviceName);");
builder.AppendLine($"service = TempoServiceRegistry.tryGetService(serviceName);");
builder.CodeBlock($"if (!(service instanceof {service.BaseClassName()}))", indentStep, () =>
{
builder.AppendLine("throw new Error('todo');");
});
builder.AppendLine($"service.setLogger(this.logger.clone(serviceName));");
builder.AppendLine("XrpcServiceRegistry.staticServiceInstances.delete(serviceName);");
builder.AppendLine("TempoServiceRegistry.staticServiceInstances.delete(serviceName);");
builder.AppendLine("this.serviceInstances.push(service);");
foreach (var method in service.Methods)
{
Expand Down Expand Up @@ -688,7 +688,7 @@ public override string Compile(Version? languageVersion, XrpcServices services =

}

if (services is XrpcServices.Client or XrpcServices.Both)
if (services is TempoServices.Client or TempoServices.Both)
{
foreach (var service in serviceDefinitions)
{
Expand Down
6 changes: 3 additions & 3 deletions Repl/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
},
"Repl": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"dotnetRunMessages": "true"
}
}
}
}

0 comments on commit b373c54

Please sign in to comment.