Skip to content

Commit

Permalink
Merge branch 'main' into adityahegde/project-breakdown
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaHegde committed Jan 7, 2025
2 parents 3974aea + 47b5007 commit 72e5109
Show file tree
Hide file tree
Showing 62 changed files with 1,827 additions and 1,140 deletions.
2 changes: 1 addition & 1 deletion admin/billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (s *Service) StartTrial(ctx context.Context, org *database.Organization) (*
if err != nil {
if !errors.Is(err, billing.ErrNotFound) {
if errors.Is(err, billing.ErrCustomerIDRequired) {
return nil, nil, fmt.Errorf("org billing not initialized yet, retry")
return nil, nil, fmt.Errorf("org billing not initialized yet")
}
return nil, nil, fmt.Errorf("failed to get subscriptions for customer: %w", err)
}
Expand Down
15 changes: 8 additions & 7 deletions admin/jobs/river/org_jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,26 +105,27 @@ func (w *StartTrialWorker) Work(ctx context.Context, job *river.Job[StartTrialAr
// org got deleted, ignore
return nil
}
w.logger.Error("failed to find organization", zap.String("org_id", job.Args.OrgID), zap.Error(err))
return err
}

org, sub, err := w.admin.StartTrial(ctx, org)
trialOrg, sub, err := w.admin.StartTrial(ctx, org)
if err != nil {
w.logger.Error("failed to start trial for organization", zap.String("org_id", job.Args.OrgID), zap.Error(err))
if job.Attempt >= job.MaxAttempts {
w.logger.Error("failed to start trial for organization", zap.String("org_name", org.Name), zap.String("org_id", org.ID), zap.Error(err))
}
return err
}

// send trial started email
err = w.admin.Email.SendTrialStarted(&email.TrialStarted{
ToEmail: org.BillingEmail,
ToName: org.Name,
OrgName: org.Name,
ToEmail: trialOrg.BillingEmail,
ToName: trialOrg.Name,
OrgName: trialOrg.Name,
FrontendURL: w.admin.URLs.Frontend(),
TrialEndDate: sub.TrialEndDate,
})
if err != nil {
w.logger.Error("failed to send trial started email", zap.String("org_name", org.Name), zap.String("org_id", org.ID), zap.String("billing_email", org.BillingEmail), zap.Error(err))
w.logger.Error("failed to send trial started email", zap.String("org_name", trialOrg.Name), zap.String("org_id", trialOrg.ID), zap.String("billing_email", trialOrg.BillingEmail), zap.Error(err))
}

return nil
Expand Down
8 changes: 5 additions & 3 deletions admin/jobs/river/river.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,11 @@ type ErrorHandler struct {
}

func (h *ErrorHandler) HandleError(ctx context.Context, job *rivertype.JobRow, err error) *river.ErrorHandlerResult {
var args string
_ = json.Unmarshal(job.EncodedArgs, &args) // ignore parse errors
h.logger.Error("Job errored", zap.Int64("job_id", job.ID), zap.Int("num_attempt", job.Attempt), zap.String("kind", job.Kind), zap.String("args", args), zap.Error(err))
if job.Attempt >= job.MaxAttempts {
var args string
_ = json.Unmarshal(job.EncodedArgs, &args) // ignore parse errors
h.logger.Error("Job failed, max attempts reached", zap.Int64("job_id", job.ID), zap.Int("num_attempt", job.Attempt), zap.Int("max_attempts", job.MaxAttempts), zap.String("kind", job.Kind), zap.String("args", args), zap.Error(err))
}
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion admin/worker/billing_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (w *Worker) reportUsage(ctx context.Context) error {
}

if len(reportedOrgs) == 0 {
w.logger.Warn("skipping usage reporting: no usage data available", zap.Time("start_time", startTime), zap.Time("end_time", endTime))
w.logger.Named("billing").Warn("skipping usage reporting: no usage data available", zap.Time("start_time", startTime), zap.Time("end_time", endTime))
return nil
}

Expand Down
13 changes: 13 additions & 0 deletions cli/cmd/devtool/data/clickhouse-config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<clickhouse replace="true">
<logger>
<level>information</level>
<console>true</console>
</logger>
<display_name>rill devtool clickhouse</display_name>
<tcp_port>9000</tcp_port>
<http_port>8123</http_port>
<timezone>UTC</timezone>
<access_control_improvements>
<select_from_information_schema_requires_grant>true</select_from_information_schema_requires_grant>
</access_control_improvements>
</clickhouse>
37 changes: 37 additions & 0 deletions cli/cmd/devtool/data/clickhouse-users.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<clickhouse replace="true">
<profiles>
<default>
<max_memory_usage>10000000000</max_memory_usage>
<use_uncompressed_cache>0</use_uncompressed_cache>
<load_balancing>in_order</load_balancing>
<log_queries>1</log_queries>
<date_time_input_format>best_effort</date_time_input_format>
</default>
</profiles>
<quotas>
<default>
<interval>
<duration>3600</duration>
<queries>0</queries>
<errors>0</errors>
<result_rows>0</result_rows>
<read_rows>0</read_rows>
<execution_time>0</execution_time>
</interval>
</default>
</quotas>
<users>
<default>
<password>default</password>
<profile>default</profile>
<quota>default</quota>
<networks>
<ip>::/0</ip>
</networks>
<access_management>1</access_management>
<named_collection_control>1</named_collection_control>
<show_named_collections>1</show_named_collections>
<show_named_collections_secrets>1</show_named_collections_secrets>
</default>
</users>
</clickhouse>
9 changes: 9 additions & 0 deletions cli/cmd/devtool/data/cloud-deps.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,12 @@ services:
command: listen --forward-to http://host.docker.internal:8080/payment/webhook --config /etc/stripe-config.toml
volumes:
- ../../../../${RILL_DEVTOOL_STATE_DIRECTORY}/stripe-config.toml:/etc/stripe-config.toml
clickhouse:
image: 'clickhouse/clickhouse-server:24.11.1.2557'
volumes:
- ./clickhouse-config.xml:/etc/clickhouse-server/config.d/config.xml
- ./clickhouse-users.xml:/etc/clickhouse-server/users.d/users.xml
- ../../../../${RILL_DEVTOOL_STATE_DIRECTORY}/clickhouse:/var/lib/clickhouse
ports:
- '9000:9000' # Native port
- '8123:8123' # HTTP port
24 changes: 16 additions & 8 deletions cli/cmd/devtool/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,11 @@ func (s cloud) start(ctx context.Context, ch *cmdutil.Helper, verbose, reset, re

g, ctx := errgroup.WithContext(ctx)

stateDir := lookupDotenv("RILL_DEVTOOL_STATE_DIRECTORY")
err = os.MkdirAll(stateDir, os.ModePerm)
err = os.MkdirAll(stateDirectory(), os.ModePerm)
if err != nil {
return fmt.Errorf("failed to create state dir %q: %w", stateDir, err)
return fmt.Errorf("failed to create state dir %q: %w", stateDirectory(), err)
}
logInfo.Printf("State dir set to %s\n", stateDir)
logInfo.Printf("State directory is %q\n", stateDirectory())

if services.deps {
g.Go(func() error { return s.runDeps(ctx, verbose) })
Expand Down Expand Up @@ -385,8 +384,8 @@ func (s cloud) resetState(ctx context.Context) (err error) {
}
}()

stateDir := lookupDotenv("RILL_DEVTOOL_STATE_DIRECTORY")
_ = os.RemoveAll(stateDir)
_ = os.RemoveAll(stateDirectory())

return newCmd(ctx, "docker", "compose", "--env-file", ".env", "-f", "cli/cmd/devtool/data/cloud-deps.docker-compose.yml", "down", "--volumes").Run()
}

Expand Down Expand Up @@ -724,8 +723,7 @@ func (s local) awaitUI(ctx context.Context) error {

func prepareStripeConfig() error {
templateFile := "cli/cmd/devtool/data/stripe-config.template"
stateDir := lookupDotenv("RILL_DEVTOOL_STATE_DIRECTORY")
outputFile := filepath.Join(stateDir, "stripe-config.toml")
outputFile := filepath.Join(stateDirectory(), "stripe-config.toml")

apiKey := lookupDotenv("RILL_DEVTOOL_STRIPE_CLI_API_KEY")
if apiKey == "" {
Expand Down Expand Up @@ -785,3 +783,13 @@ func lookupDotenv(key string) string {
}
return env[key]
}

// stateDirectory returns the directory where the devtool's state is stored.
// Deleting this directory will reset the state of the local development environment.
func stateDirectory() string {
dir := lookupDotenv("RILL_DEVTOOL_STATE_DIRECTORY")
if dir == "" {
dir = "dev-cloud-state"
}
return dir
}
17 changes: 11 additions & 6 deletions cli/cmd/project/connect_github.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,18 @@ func ConnectGithubFlow(ctx context.Context, ch *cmdutil.Helper, opts *DeployOpts
}
}

// If the Git path is local, we'll do some extra steps to infer the githubURL.
localGitPath, localProjectPath, err := ValidateLocalProject(ch, opts.GitPath, opts.SubPath)
if err != nil {
if errors.Is(err, ErrInvalidProject) {
return nil
var localGitPath string
var localProjectPath string
var err error
if isLocalGitPath {
// If the Git path is local, we'll do some extra steps to infer the githubURL.
localGitPath, localProjectPath, err = ValidateLocalProject(ch, opts.GitPath, opts.SubPath)
if err != nil {
if errors.Is(err, ErrInvalidProject) {
return nil
}
return err
}
return err
}

if ch.Org != "" {
Expand Down
4 changes: 3 additions & 1 deletion docs/docs/contact.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ For individuals that prefer a more traditional email medium, you can open a supp

### In-app chat

For logged-in users, Rill provides an ability to ask a question and/or report an issue to the Rill Support team from within the application directly via an embedded in-app chat widget. More details to come soon!
For logged-in users, Rill provides an ability to ask a question and/or report an issue to the Rill Support team from within the application directly via an embedded in-app chat widget. Select your user icon in the top right corner and select "Contact Rill support" and a chat widget will appear on your screen!

![rill-chat](/img/contact/rill-developer-chat.png)
Binary file added docs/static/img/contact/rill-developer-chat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 72e5109

Please sign in to comment.