GithubHelp home page GithubHelp logo

Comments (16)

thantos avatar thantos commented on May 15, 2024 1

Keep it simple? Anyone can make another overload and more l2s?

from functionless.

sam-goodwin avatar sam-goodwin commented on May 15, 2024 1

Yeah, I think this is better! We can provide an escape hatch if folk want to pass a pre-existing function

image

from functionless.

thantos avatar thantos commented on May 15, 2024 1

Uhhgg, yeah, good point. Lets enforce the singleton when the automatic name is used?

from functionless.

sam-goodwin avatar sam-goodwin commented on May 15, 2024

How should we go about layering this?

  1. L1 Queue - no type information, all APIs use the vanilla AWS SDK APIs, e.g. MessageBody: string
  2. L2 Queue<T> - captures type information and provides serialization/deserialization utility?

For supporting an arbitrary T, we will need some Codec<T> type that encapsulates serialization/deserialization logic.

export interface ReadCodec<Value, Data> {
  read(data: Data): Value;
}
export interface WriteCodec<Value, Data> {
  write(value: Value): Data;
}
export interface Codec<Value, Data>
  extends ReadCodec<Value, Data>,
    WriteCodec<Value, Data> {}

export class JsonCodec<T> implements Codec<T, string> {
  public read(data: string): T {
    return JSON.parse(data);
  }
  public write(value: T): string {
    return JSON.stringify(value);
  }
}

from functionless.

thantos avatar thantos commented on May 15, 2024

Could we do the same contract as secret?

Textqueue and jsonqueue?

Roll parse into the integration?

from functionless.

sam-goodwin avatar sam-goodwin commented on May 15, 2024

Could we do the same contract as secret?

Textqueue and jsonqueue?

Roll parse into the integration?

I was thinking the same, although we may need to consider cases like Avro, ProtoBuf, Flatbuffers, etc. So i was wondering if we could have a Codec abstraction - quickly run into limitations with closure serialization and this though.

from functionless.

sam-goodwin avatar sam-goodwin commented on May 15, 2024

That said, JsonSecret likely covers 99% of cases ha

from functionless.

sam-goodwin avatar sam-goodwin commented on May 15, 2024

for JsonQueue<T>, where should we place the parsed value?

interface SQSRecord<T> {
  body: string; // <- this is the vanilla AWS API
  value: T; // <- maybe we add a new field? Or should we override body?
}

from functionless.

thantos avatar thantos commented on May 15, 2024

Make it explicit to not polite the sfn state?

from functionless.

sam-goodwin avatar sam-goodwin commented on May 15, 2024

Make it explicit to not polite the sfn state?

I don't know what you mean?

from functionless.

sam-goodwin avatar sam-goodwin commented on May 15, 2024

Hmm, if this is the interface

public forEach(
    handler: Function<SQSEvent<T>, lambda.SQSBatchResponse>,
    props?: aws_lambda_event_sources.SqsEventSourceProps
  ): void {
    handler.resource.addEventSource(
      new aws_lambda_event_sources.SqsEventSource(this.resource, props)
    );
  }

And we want to inject code that parses the body string, how would we inject that into the Function?

Should we instead change the interface to be

public forEach(scope: Construct, id: string, props: FunctionProps & SqsEventSourceProps, handle: (event: ..) => ..)

And then have the forEach instantiate the Function?

from functionless.

thantos avatar thantos commented on May 15, 2024

Looks good to me, and make the scope optional?

from functionless.

sam-goodwin avatar sam-goodwin commented on May 15, 2024

Looks good to me, and make the scope optional?

Yep, even id can default to "forEach"

from functionless.

sam-goodwin avatar sam-goodwin commented on May 15, 2024

Looks good to me, and make the scope optional?

Yep, even id can default to "forEach"

Which would work in 99% of cases because it's not like you'd ever attach two consumers

from functionless.

thantos avatar thantos commented on May 15, 2024
let n = 0;
let name = "forEach";
do {
   const child = queue.node.tryFindChild(name);
   if(!child) {
      break;
   }
  name = `forEach${++n}`;
} while(true);

from functionless.

sam-goodwin avatar sam-goodwin commented on May 15, 2024
let n = 0;

let name = "forEach";

do {

   const child = queue.node.tryFindChild(name);

   if(!child) {

      break;

   }

  name = `forEach${++n}`;

} while(true);

Sure that would work. But it has risks because of you remove one in the middle they all change.

from functionless.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.