Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cargo-pgx template support #490

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

jamessewell
Copy link
Contributor

@jamessewell jamessewell commented Mar 21, 2022

They replace the previous single shot bgworker config switch

All files are templated out of the ./src/templates directories

Possible to do:

  • check (at compile time) that templates have a MVP list of files (./src/lib.rs, Cargo.toml etc..)
  • Build (at compile time) a list of ./src/template directories to include (static atm)

…o-pgx

to replace the previous bgworker config

All files are templated out of the ./src/templates directories

Possible to do:

- check (at compile time) that templates have a MVP list of files (./src/lib.rs, Cargo.toml etc..)
- Build (at compile time) a list of ./src/template directories to include (static atm)
@Hoverbear Hoverbear changed the title These changes are a first go at a concept of cargo-pgx templates cargo-pgx template support Mar 21, 2022
@@ -1,41 +1,74 @@
[package]
name = "cargo-pgx"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be quite a bit of unrelated changes in this file.

use serde::{Deserialize, Serialize};
use structmap::{value::Value, GenericMap, StringMap, ToMap};
use structmap_derive::ToMap;

/// Create a new extension crate
#[derive(clap::Args, Debug)]
#[clap(author)]
pub(crate) struct New {
/// The name of the extension
name: String,
/// Create a background worker template
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Create a background worker template
/// Create an extension from a template


// This is an example of a basic agg which adds values to a HashSet
// then returns the number of elements which have been added
// see https://hoverbear.org/blog/postgresql-aggregates-with-rust/ for more examples
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, we should add this to /articles in the repo...

pg_module_magic!();

#[derive(Copy, Clone, Default, Debug)]
pub struct {{ camel-case name }};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit unfortunate how the template syntax is so similar to Rust :|

@Hoverbear
Copy link
Contributor

All in all I'm pretty pleased with this @jamessewell . :) In your commit you mentioned this was a first go, are you planning on making further changes or should I take it for a spin?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants